I am working with ActiveMapViewChanged event as shown in the code snippet.
private void SubscribeMapEvents()
{
...
ActiveMapViewChangedEvent.Subscribe(UpdateUIElements);
}
private void UpdateUIElements(ActiveMapViewChangedEventArgs obj)
{
if (obj.IncomingView != null){
ReInitializeUIElements();
}
else
{
ResetUIElements();
}
}
Idea is to
The event triggers correctly when there is no map with IncomingView value as null, and when it updates the event is triggered with active map view's instance in the IncomingView parameter.
Whereas, when I open an attribute table from Table of contents with an active map, this event is triggered twice.
This behavior is causing an unwanted reset of the controls even when there is an active map present.
Solved! Go to Solution.
Hi,
I would suggest that you should use ActivePaneChangedEvent instead. The type of pane returned when the Active Pane changes will tell you if it is a Map Pane or a Table. It will be MapPaneViewModel for an Active Map or TablePaneViewModel for a Table. Code snippet:
//Subscribe to event
ArcGIS.Desktop.Framework.Events.ActivePaneChangedEvent.Subscribe(OnActivePaneChanged);
private void OnActivePaneChanged(PaneEventArgs obj)
{
if (obj.IncomingPane != null)
{
System.Diagnostics.Debug.WriteLine($"Debug Message. GetTypeName: {obj.IncomingPane.GetType().Name}");
}
}
A little background on the behavior you are seeing with ActiveMapViewChanged event -
When you display the attribute table of a feature layer in the Active map, the IncomingView is first null (which is correct).
The attribute table pane then becomes the active pane. But when the attribute table pane is active, the TOC that lists the layers needs to know the “context” of which map it needs to use.
So the Attribute table pane that is currently active, “impersonates” the Map Pane. Hence the event gets triggered again and the Incoming View is now the “Map” associated with the attribute table.
Thanks
Uma
Hi,
I would suggest that you should use ActivePaneChangedEvent instead. The type of pane returned when the Active Pane changes will tell you if it is a Map Pane or a Table. It will be MapPaneViewModel for an Active Map or TablePaneViewModel for a Table. Code snippet:
//Subscribe to event
ArcGIS.Desktop.Framework.Events.ActivePaneChangedEvent.Subscribe(OnActivePaneChanged);
private void OnActivePaneChanged(PaneEventArgs obj)
{
if (obj.IncomingPane != null)
{
System.Diagnostics.Debug.WriteLine($"Debug Message. GetTypeName: {obj.IncomingPane.GetType().Name}");
}
}
A little background on the behavior you are seeing with ActiveMapViewChanged event -
When you display the attribute table of a feature layer in the Active map, the IncomingView is first null (which is correct).
The attribute table pane then becomes the active pane. But when the attribute table pane is active, the TOC that lists the layers needs to know the “context” of which map it needs to use.
So the Attribute table pane that is currently active, “impersonates” the Map Pane. Hence the event gets triggered again and the Incoming View is now the “Map” associated with the attribute table.
Thanks
Uma
Thanks for the explanation of ActiveMapViewChanged event.
ActivePaneChanged event helps resolve the issue. Cheers!