Select to view content in your preferred language

Drag item from custom DockPane and Drop on a Map

875
2
01-15-2020 06:34 AM
JaneDoe
New Contributor

Hi

Can anyone provide a sample on how to handle the Drop event of a custom item (not a file) on a Map or Scene?

The Drag operation is initiated on the TreeView of a custom DockPane as specified in ProConcepts Framework · Esri/arcgis-pro-sdk Wiki · GitHub and seems to work just fine. That is, StartDrag() is called on dragging a TreeViewItem and the cursor receives the 'not droppable' effect, which is probably ok since the Drop target has not yet been defined.

public void StartDrag(DragInfo dragInfo)
{
    dragInfo.Data = "SELECTED LAYER...";
    dragInfo.Effects = DragDropEffects.Move;
}

Custom Drop handlers for files (with the specified extensions) can be defined in DAML (https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#custom-drop-handlers-in-daml😞

<insertHandler id="DragDropExample_ExcelDropHandler" className="ExcelDropHandler" dataTypes=".XLSX|.xlsx|.XLS|.xls" />

I couldn't find a way though to employ them for the Drop of a custom item. Is there another way to make the Map a Drop target for my TreeViewItem?

Thanks!

Tags (1)
0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi Monika

To drag and drop a custom item, implement the IMappableItem interface  

You will have to implement the following 2 methods on your custom item:

1. CanAddToMap Method: Return true here to allow the items to be dropped on a Map or Scene.

2. OnAddToMap method: This is where you add your logic that allows you to display your item in the map. It could be where you load your plugin, or run a GP tool, etc.

The Custom item guide and samples will be updated with this info when Pro 2.5 is released next week.

Thanks!

Uma

JaneDoe
New Contributor

Thanks for your reply!

Didn't get the IMappableItem option to run (no sample found), but the following sample shows another option to achieve the same result (point 11. - drag from TreeView and drop to Map):

arcgis-pro-sdk-community-samples/Framework/DragAndDrop at master · Esri/arcgis-pro-sdk-community-sam... 

Populating the ItemInfoValue object with the Item information provided by ItemFactory.Instance.Create() makes the cursor receive the 'droppable' effect when over a Map or Scene.

0 Kudos