Hello,
I'm trying to open the layout properties window without much success.
var wrapper = FrameworkApplication.GetPlugInWrapper("esri_layouts_propertySheet");
var command = wrapper as ICommand;
if (command == null)
return;
// execute the command
if (command.CanExecute(null))
command.Execute(null);
I have an activeView. But the wrapper is always null.
Any idea ? Thanks !
Solved! Go to Solution.
The reason why you get a <null> returned is because this item doesn't implement an ICommand (i.e. button). If you use esri_layouts_layoutPropertiesButton instead of the property page DAML, your code should work. To find the appropriate DAML Id you can either use the DAML reference here: DAML ID Reference ArcGISLayout.daml · ArcGIS/arcgis-pro-sdk Wiki (github.com) or you can enable the this Pro option:
Once enabled you can see the DAML Id as a tooltip:
The reason why you get a <null> returned is because this item doesn't implement an ICommand (i.e. button). If you use esri_layouts_layoutPropertiesButton instead of the property page DAML, your code should work. To find the appropriate DAML Id you can either use the DAML reference here: DAML ID Reference ArcGISLayout.daml · ArcGIS/arcgis-pro-sdk Wiki (github.com) or you can enable the this Pro option:
Once enabled you can see the DAML Id as a tooltip:
Here is a code snippet to help you -
//Get the selected item in the Catalog pane
//Cast as Layout Project item.
var selectedLayout = Project.GetCatalogPane(true)?.SelectedItems.FirstOrDefault() as LayoutProjectItem;
if (selectedLayout == null) return;
//Call Pro's Command to open the selected layout
// ArcGIS Pro Command's DAML ID.
var commandId = "esri_layouts_projectItem_LayoutProperties";
// get the ICommand interface from the ArcGIS Pro Button
// using command's plug-in wrapper
var iCommand = FrameworkApplication.GetPlugInWrapper(commandId) as ICommand;
if (iCommand != null)
{
// Let ArcGIS Pro do the work for us
if (iCommand.CanExecute(null))
{
iCommand.Execute(null);
}
}