I'm working with ArcGIS Pro 2.6 and when I add a layout by code and activate the mapframe in the layout, it is not responding any longer. The ribbons are grayed out and the Layout cannot be reactivated. When I import the same layout from the catalog pane, it is working correctly. There is just one default layer in the map on the layout. When I wait long enough I can close the map frame and return to the layout. To activate the map frame now is not a problem any more.
Code for adding the layout:
var layout = await QueuedTask.Run(() => GetLayout(selectedLayoutPath, name));
private Layout GetLayout(string path, string layoutname)
{
var pathDef = string.Concat(path, @\, layoutname, @.pagx);
var layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(layoutname));
if (layoutItem != null)
{
Project.Current.RemoveItem(layoutItem);
}
var pagx = (IProjectItem)ItemFactory.Instance.Create(pathDef);
Project.Current.AddItem(pagx);
layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(layoutname));
return layoutItem.GetLayout();
}
Is there another method to add a layout to the project or is it a known bug? I saw other posts with problems on changing map frames on layouts.
I also used the ArcGIS Diagnostic Monitor and the process bugged on
ArcGIS.Desktop.Internal.Layouts.Ribbon.MapSeriesGalleryItem.RefreshAsync+
100 05:23:41:595 431439 431439 0 0
I hope somebody can tell me what the problem is.