Select to view content in your preferred language

How to drag a feature class from catalog pane into Combo Box using Drag and Drop functionality?

463
5
07-10-2024 08:11 AM
AbhijeetNandeshwar1
Occasional Contributor

Hello @UmaHarano , @Wolf ,

Hope you are doing well.

I am trying to Drag a feature class from the Catalog pane and trying to drop into a combo box using drag and drop functionality. However, I tried tweaking the sample https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#dropping-on-a-pane  for my goal but I didn't helped. 

I am able to get the path of the feature class. but I don't know how I can proceed further to populate it as feature class. I have attached the screenshot of my goal.

 

 

 

 else if (dropInfo.Data is List<ClipboardItem> clipboardItems)
 {
     // in this example, we handle just the first item if there are multiples being dragged
     var catalogItem = clipboardItems.First();
     string url = catalogItem.CatalogPath;
     Uri uri = new Uri(url);
    
     // SelectedFeatureLayer = catalogItem.CatalogPath.ToString();
     {
         dropInfo.Handled = false;
         //ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Drag and drop only from the TOC here");
         return;
     }

 

 

Looking forward for your suggestion.

Regards,

Abhijeet

 

 

MY GOALMY GOALScreenshot (13).png

5 Replies
UmaHarano
Esri Regular Contributor

Hi @AbhijeetNandeshwar1 

Here is a sample attached. Search for TODO to see the specific items for the drag/drop implementation.

UmaHarano
Esri Regular Contributor

Note: The attachment above had a version of 3.4 in the config.daml.  I have update the sample attachment now with version 3.3

AbhijeetNandeshwar1
Occasional Contributor

Thank you for your help @UmaHarano . But I converted it 3.3 to test the application. I have created a small video that demonstrates my goal. Please go through it. I apologize if I was not able to clarify my workflow.

My goal is to populate the feature class into the combo box. The sample you sent is giving me the path of the feature class.

let me frame the questions, How can I convert the URL to feature layer or feature class? However I tried converting the URL to feature layer. It's forcing me to add the layer to active map which I don't want to.

      string url = @"c:\data\project.gdb\roads";  //FeatureClass of a FileGeodatabase
      Uri uri = new Uri(url);
      await QueuedTask.Run(() => LayerFactory.Instance.CreateLayer(uri, MapView.Active.Map));

Please let me know if I can help you in any way.

Thank you,
Abhijeet

UmaHarano
Esri Regular Contributor

Check out the ProSnippet: Geodatabase wiki. It has some good info on how to work with accessing the feature classes from the underlying Geodatabase - given the URL that you already have.

Please reach out if you get stuck.

Wolf
by Esri Regular Contributor
Esri Regular Contributor

If you drag an 'Item' from the Catalog pane (specifically a Geodatabase item) you will have a Feature Class or a Table.  Feature Layers are part of the map, so you can't have a feature layer without adding a feature class to the map first.  However, you can perform operations on Feature Classes as well as Tables.   I attached a drag/drop sample the takes a dropped feature class (point) or table and displays it's content.  The sample requires 3.3

Dragging a Point feature classDragging a Point feature classShowing the dropped contentShowing the dropped content