ActiveMapViewChanged和选择变化
/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}");
}
}
===========================
private SubscriptionToken eventToken = null;
private void SetupEvents()
{
eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
}
private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs obj)
{
//do work on the selection
}
=========================调用方法===
private SubscriptionToken eventToken = null;
private void SetupEvents()
{
eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
}
private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs obj)
{
//do work on the selection
MessageBox.Show("变化"+obj.Selection.Count.ToString());
}
protected async override void OnClick()
{
SetupEvents();
}