I am displaying a data grid of custom information in my Pro add-in. I have added this to a pane, however, when this pane is activated, the Contents dock pane is empty until a map view is again set as the active pane. I would like the Contents to remain populated with layers from the active map view, similar to how charts and attribute table panes work. When I add the data grid to a dock pane instead of a ViewStatePane, I do get this behavior, but then I cannot dock this pane to the map view. Is there a way to do this?
Dockpane is the correct way to go. The best you can do on the docking is dock to the application window (left, right, top, bottom) - it does not support docking to a Pane (map, layout, etc) as you mention.
Conceptually, Pro has an Active pane (the one with focus). The TOC (amongst other things) keys off this and changes its contents to match whichever pane is active. Therefore, when you try to use a Pane (and not a ~dock~ pane), even though you get the docking behavior you want, activating your Pane de-activates the previously active pane (eg a map) and the TOC, seeing that ~your~ pane is not a mapview, it empties.
There are special cases in Pro where the context needs to be maintained even though a MapView does not have focus. For example, if you open a layer attribute table the TOC remains unchanged and the MapView.Active property is still valid. In this case, the table pane instance (hosting the attribute table) is providing the proper context to the TOC (for the mapview that contains the layer whose attributes are being shown) to keep the TOC populated. However, the code to do that is all internal and is not exposed in the API. Currently there are no plans to support this.
I updated the Layer Pane sample which I think does what you need: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane
Can you check the sample and see if it satisfies your workflow needs?
I pulled your changes from the last commit "Simplified code to manage DataGrid control", but I cannot see any major changes to the view model acting as a view pane. Would you be so kind and validate if you pushed the changes you made to the public repository or maybe it is just committed to your local one?
I misunderstood the original question, even with the updated sample the 'Contents' dockpane's TOC is 'emptied' when the 'Pane' is activated. Sorry about the confusion. So Charlie's answer from above stands: currently this feature is not supported.
Is there an update to this issue? I am using the Pro SDK 1.4.1 and just want to programmatically open (show) the attribute table from a standalone table listed in the TOC. Thanks.
This will be possible with the 2.0 release of the Pro SDK. We anticipate 2.0 to be released end of June. There will be a new Visual Studio item template that can be used to create a pane that is linked to an active map. When 2.0 is released, there will be Pro SDK Samples and guides to help with this.
In the meantime, you could download the ArcGIS Pro 2.0 Beta to experiment with this functionality to get ready for the final release.
Thank you very much for the quick reply and update.
CEO Quartic Solutions
1804 Garnet Ave. #447
San Diego, CA 92109
mobile: (619) 602-7606