Can I open the layout properties dialog programmatically?

385
1
06-07-2018 01:19 PM
AnthonyMikelson
New Contributor III

Following is the code I am attempting to use to open the layout properties dialog programmatically:

var command = FrameworkApplication.GetPlugInWrapper(@"esri_layouts_projectItem_LayoutProperties") as ICommand;
if (command != null)
{
// get the layout project item
var layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Path.Equals(this.LayoutUri));
if (layoutItem != null)
{
if (command.CanExecute(layoutItem))
command.Execute(layoutItem);
}
}

If I change the parameter for the GetPlugInWrapper to "esri_layouts_layoutPropertiesButton", I can open the layout properties for the currently active layout pane, however that is not what I am looking to do. 

What do I need to pass into the command.CanExecute parameter to use the "esri_layouts_projectItem_LayoutProperties" button?

Thank you,

Tony

0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor

This will be addressed with Pro 2.3.  The solution will be:

LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout"));
Layout lyt = await QueuedTask.Run(() =>
{
    return layoutItem.GetLayout();
});
lyt.ShowProperties();