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