I know there are already several posts, but none quite what I need. I've got a custom dockpane which lists data from three different sources in three different treeviews. let's start with the vectors.
I can select my items and drop them on my vector_treeview which adds them with my custom method to my map.
at the start I have
vector_gdbTreeView.PreviewMouseLeftButtonDown += vector_DirectoryTreeView_PreviewMouseLeftButtonDown;
vector_gdbTreeView.PreviewMouseMove += vector_DirectoryTreeView_PreviewMouseMove;
vector_gdbTreeView.AllowDrop = true;
vector_gdbTreeView.Drop += vector_DirectoryTreeView_Drop;
and then the methods
private async Task AddVectorToMapMethod_string(string data_path)
{
...
}
private System.Windows.Point startPoint;
private void vector_DirectoryTreeView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
startPoint = e.GetPosition(null);
}
private void vector_DirectoryTreeView_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
System.Windows.Point mousePos = e.GetPosition(null);
Vector diff = startPoint - mousePos;
if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
{
System.Windows.MessageBox.Show(string.Join(Environment.NewLine, vector_selectedFileUrls), "Items");
// only handle one selected url
DataObject dragData = new DataObject("MyFormat", vector_selectedFileUrls.ToList()[0].ToString());
DragDrop.DoDragDrop(vector_gdbTreeView, dragData, DragDropEffects.Move);
}
}
}
private async void vector_DirectoryTreeView_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("MyFormat"))
{
var droppedData = e.Data.GetData("MyFormat");
if (droppedData != null)
{
await QueuedTask.Run(async () =>
{
// Perform your drop operation here based on droppedData
await AddVectorToMapMethod_string(droppedData.ToString());
});
}
}
}However I cannot figure out how to allow dropping it also in the table of content or on the map directly or on the entire surface of ArcGIS Pro. I thought I just need to set AllowDrop on those elements, but I cannot figure out how to reference these elements so that it allows AllowDrop... Can anyone please help me? thank you in advance 🙂