Select to view content in your preferred language

Event for Layer Name Change

1490
4
10-23-2019 12:46 PM
SusanFarley
Occasional Contributor

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.

0 Kudos
4 Replies
UmaHarano
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

0 Kudos
SusanFarley
Occasional Contributor

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

0 Kudos
Vidar
by
Frequent Contributor

the link doesn't work anymore @UmaHarano 👍

0 Kudos
UmaHarano
Esri Regular Contributor

@Vidar I have fixed the link now. Thanks for catching that.

0 Kudos