Select to view content in your preferred language

How to programmatically open the "Export Layout" pane from a custom DockPane (Pro 3.3)?

71
1
Friday
Zoggo
by
Occasional Contributor

Hello everyone,

I am developing an ArcGIS Pro 3.3 Add-in (C#) and I am trying to open the standard "Export Layout" pane from a button on my custom DockPane.

My goal is to provide the same user experience as clicking the "Export Layout" button in the "Share" ribbon tab. The export pane should open, automatically referencing the currently active layout.

I have tried several different approaches based on documentation and community threads, but none have worked reliably.

What I Have Tried:

1. Using ExecuteCommand with Command IDs

These commands do not seem to do anything when called from my DockPane's ViewModel, even when a layout view is active.

// These attempts do nothing
FrameworkApplication.ExecuteCommand("esri_layouts_exportLayoutButton");
// or
FrameworkApplication.ExecuteCommand("esri_layouts_exportLayout");
// or (to open the Backstage)
FrameworkApplication.ExecuteCommand("esri_share_ShareExportLayout");

2. Using DockPaneManager.Find

This method only works if the user has already opened the export pane in their current Pro session. If it has never been opened, Find() returns null.

// Fails if the pane has not been opened yet (exportPane is null)
DockPane exportPane = FrameworkApplication.DockPaneManager.Find("esri_layouts_exportPane");

if (exportPane == null)
{
    // How do I open it for the first time?
}
else
{
    exportPane.Activate();
}

3. Using Geoprocessing.OpenToolDialogAsync (This seemed most promising)

This approach fails with a RuntimeBinderException when trying to pass the layout as a parameter.

private async Task ExecutePlotExportieren()
{
    var layoutView = LayoutView.Active;
    if (layoutView == null)
    {
        MessageBox.Show("No active layout found.");
        return;
    }

    // Attempt 1: Passing the Layout object
    // This fails with a RuntimeBinderException:
    // "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'The best overloaded method match for 'ArcGIS.Desktop.GeoProcessing.ObjectToValueConverter.to_string(ArcGIS.Desktop.Mapping.MapMember, out object)' has some invalid arguments'"
    var parameters = Geoprocessing.MakeValueArray(layoutView.Layout);

    // Attempt 2: Passing the Layout name (string)
    // This also fails with the same RuntimeBinderException.
    // var parameters = Geoprocessing.MakeValueArray(layoutView.Layout.Name);

    await Geoprocessing.OpenToolDialogAsync("management.ExportLayout", parameters);
}

My Question:

What is the correct and reliable method in the ArcGIS Pro 3.3 SDK to programmatically open the standard "Export Layout" pane (or Backstage page) and have it target the currently active layout?

Thank you for your help!

0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

Active layout must be selected before executing code below:

        protected override void OnClick()
        {
            var command = FrameworkApplication.GetPlugInWrapper("esri_sharing_ExportLayout") as ICommand;
            if (command.CanExecute(null))
                command.Execute(null);
        }

 

0 Kudos