I have a Feature Service in my Map, no local sde files or file geodatabase (aside from default.gdb which I do not use).
I published this service with Version Management set to "true", from a Map with layers that reference a Branch - Versioned dataset.
Is the only way to retrieve the data source is by iteration through layer(s) using the ArcGIS Pro SDK? I am trying to create a custom versioning tool and I wanted to place it in the same Tab as the other Versioning commands, and when that tab is active, no layers are selected in the TOC. How do the existing commands (Post, Reconcile, Manage Versions etc) know the current selected data source? I even tried subscribing to TOCSelectionChangedEvent, however the only arguments returned are MapViewEventArgs, which do not contain any context about selected Datasource in the TOC.
Getting back to the original question:
Is the only way to retrieve the data source is by iteration through layer(s) using the ArcGIS Pro SDK?
You don't need to iterate through all layers - you can just loop through layers that belong to the currently selected datasource on the datasource tab.
This can be done with a command that retrieves the currently selected DataSourceMember from the tab (via MapView's GetSelectedDataSource member) , then loops through DataSourceMember.GetMapMembers , which should be all the layers that use that datasource.
You can arbitrarily pick the first member of the GetMapMembers to determine what datasource is selected in the UI.
To add the command to this context menu:
Use DAML like this:
thz a lot