Notification of active edit template change

12-16-2018 12:01 AM
New Contributor III

Greetings.  I am trying to get notification when the active edit template changes.  There doesn't seem to be an event available to handle this, so I am listening for PropertyChanged events on all the edit templates and checking for the "IsActive" property name (see code below).  The problem I am encountering is that the handler is getting called multiple times on the same template for the "IsActive" property name, but the property is not changing.  I don't see the IsActive property change to "true" except when the active tool doesn't change. 

So, if my current layer is polygon and I change to a different layer that is also polygon, the IsActive property does change to "true" on the new template.  Also, if the current layer has subtypes and I'm just changing to a different subtype within the same layer, then the property value changes as expected.  However, changing between layers of different geometry types (which triggers a change in the active tool) results in the property changed handler never getting notified of the active template.  The calls are being made, but the value for IsActive is always false.

My question is, what is the most efficient way to get notification of active edit template changes?  Thank you.

public bool Register()
   var layers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
   QueuedTask.Run(() =>
      foreach (var fl in layers) {
         foreach (var template in MappingExtensions.GetTemplates(fl)) {
            template.PropertyChanged +=
               new PropertyChangedEventHandler(TemplatePropertyChanged);

private void TemplatePropertyChanged(Object sender, PropertyChangedEventArgs args)
   if (args.PropertyName == "IsActive") {
      EditingFeatureTemplate template = sender as EditingFeatureTemplate;
      // Do something

0 Replies