Event for Layer Name Change

65
2
10-23-2019 12:46 PM
Highlighted
New Contributor III

Is there any event that I can subscribe to for seeing when the layer name is changed? I was hoping for something similar to LayersAddedEvent or LayersRemovedEvent.

Reply
0 Kudos
2 Replies
Highlighted
Esri Regular Contributor

You can use the MapMemberPropertiesChangedEvent class.  The MapMemberPropertiesChangedEventArgs class has an "EventHint" property that can be used to find if the Name has changed.

Thanks

Uma

Reply
0 Kudos
Highlighted
New Contributor III

I have subscribed to this event but now have a slight issue that I don't understand. Do my code is this:

In the main form:

private void LayersChanged (MapMemberPropertiesChangedEventArgs obj)

   {

      cLayerSelection.RefreshLayerSelection();

   }

Then in the cLayerSelect control I have:

public void RefreshLayerSelection() {

   if (arcFac == null) return;

   arcFac.GetLayers();

   foreach (FeatureLayer fl in arcFac.LinkLayers)

      layeritems.Add(fl);

   foreach (FeatureLayer fl in arcFac.NodeLayers)

      layeritems.Add(fl);

   UpdateLayerGrid(); //this is a grid where the Items are set to the global variable layerItems

}

public void UpdateLayerGrid()

{

   gridLayers.RefreshData(); //this throws an error 'System.InvalidOperationException' occurred ... The calling thread cannot access this object because a different thread owns it. 

 }

I call RefreshLayers from the LayersAddedEvent and LayersRemovedEvent and do not get this error. What is causing it?

Thank you,

Susan

Reply
0 Kudos