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?
Solved! Go to Solution.
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:
//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
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:
//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
That worked great. Thanks!