Select to view content in your preferred language

How do I access currently selected Datasource from Pro SDK

6221
11
07-23-2019 01:46 PM
by Anonymous User
Not applicable

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.

0 Kudos
11 Replies
KirkKuykendall1
Frequent Contributor

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:

KirkKuykendall1_1-1639064709818.png

Use DAML like this:

KirkKuykendall1_0-1639064667422.png

 

 

 

pspada_WT
Regular Contributor

thz a lot

0 Kudos