Hide dockpane based on state

2471
7
02-08-2017 07:12 AM
BenoitPronovost1
New Contributor III

I have a dockpane that displays selected items in a data grid and allows the user to select a row and open it's asset information in SAP. After checking if the SAP connexion is valid I set a state. I've set the condition on the button that opens the dockpane, which works fine, but if the pane is already open, it remains open in the interface. 

I was wondering if it is possible to close a dockpane or disable it's controls based on a state/condition value? 

Thank you,

Benoit

Tags (2)
0 Kudos
7 Replies
UmaHarano
Esri Regular Contributor

Hi Benoit

Just some clarification to understand your issue -

When you open an ArcGIS Pro project, it remembers the Dockpanes that were open previously. So in your case, when the project opens up, the SAP connection is not valid, but still the controls in your Dockpane are visible\enabled. Is this what you are trying to solve?

Thanks

Uma

0 Kudos
BenoitPronovost1
New Contributor III

Hi Uma, this is exactly what I'm trying to solve.

Thanks

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Benoit

You can accomplish this by:

  • Set the "autoLoad" property in your Config.daml to true. This will allow your add-in to load automatically when ArcGIS Pro starts. The default setting for this property is false.
  • In your Dockpane's view model, override the InitializeAsync method of the dockpane.  Inside this method, check the status of your SAP connection and set a Boolean property.  This property can then be used to bind to your controls in your Dockpane xaml - to set their enabled\disabled or visibility states.

Thanks

Uma

BenoitPronovost1
New Contributor III

Thank you Uma,

I was hoping for a less "code behind" solution but I guess I will manage something your solution.

Benoit

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Benoit

Correction: You do not have to set the autoload property to true in your example. The add-in should work with this property set to false (default value).

Thanks

Uma

0 Kudos
LesleyBross1
New Contributor III

I would like to hide the dockpane completely when the Pro client is launched. I have tried overriding the InitializeAsync() and calling the hide method on the DockPane object, but it still appears. Is there no way to hide a dockpane if it was open during the previous session of Pro?

0 Kudos
BarbaraSchneider2
Occasional Contributor II

I have the same question as Leslie. I want my dockpane to be closed when the project is opened. I solved this problem by closing the dockpane when ArcGIS Pro is shut down. I use the following code in my module:

protected override bool CanUnload()
{                
    DockPane dockPane = FrameworkApplication.DockPaneManager.Find(_myDockPaneID);
    if (dockPane != null)
    {
        dockPane.IsVisible = false;
    }
    return true;
}