Changing Panes after CreateMapPaneAsync()

110
2
Jump to solution
03-30-2020 10:41 AM
JeffBoyton
New Contributor II

I am trying to create a new Map pane (with a new map in it) but keep the current layout pane I am on active.  When I run these lines:

string mapName = $"{Name} Map";
Map newMap = await QueuedTask.Run(() => MapFactory.Instance.CreateMap(mapName));
Pane layoutPane = ProApp.Panes.ActivePane;
await ProApp.Panes.CreateMapPaneAsync(newMap);
layoutPane.Activate();

I see the new pane get created and start initializing, then the layout is selected, then the new pane is re-selected (presumably when it finishes initializing).  What do I need to do to come out of this code with the layout as my active pane?

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi Jeff

CreateMapPaneAsync triggers other internal events in Pro that does the initialization and opening of the map pane routines.  

One way you could accomplish what you need is by:

  • Subscribing to the DrawCompleteEvent. In the event handler, once your "Map" opens, activate the layout pane.
//In your module class initialize call back
protected override bool Initialize(){
ArcGIS.Desktop.Mapping.Events.DrawCompleteEvent.Subscribe(OnDrawComplete);
return base.Initialize();
}
//Remember to unsubscribe so that thsi happens only once (if that is the behavior you need)
private void OnDrawComplete(MapViewEventArgs obj) {
if (obj.MapView.Map.Name == "New Map")
{
Module1.LayoutPane.Activate();
}
}

Thanks

Uma

View solution in original post

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi Jeff

CreateMapPaneAsync triggers other internal events in Pro that does the initialization and opening of the map pane routines.  

One way you could accomplish what you need is by:

  • Subscribing to the DrawCompleteEvent. In the event handler, once your "Map" opens, activate the layout pane.
//In your module class initialize call back
protected override bool Initialize(){
ArcGIS.Desktop.Mapping.Events.DrawCompleteEvent.Subscribe(OnDrawComplete);
return base.Initialize();
}
//Remember to unsubscribe so that thsi happens only once (if that is the behavior you need)
private void OnDrawComplete(MapViewEventArgs obj) {
if (obj.MapView.Map.Name == "New Map")
{
Module1.LayoutPane.Activate();
}
}

Thanks

Uma

View solution in original post

0 Kudos
JeffBoyton
New Contributor II

That worked great.  Thanks!

0 Kudos