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.