I am working with a WPF application that is using Drag and Drop functionality.
The Drag and Drop operation is a blocking operation and is having some negative side effects in my application. I have recently added the use of an adorner to show the item dragging. The problem with this is that in order to do this, I need to track the current position of the mouse. When a Drag and Drop operation is initiated, it blocks further execution until the item is dropped.
I have read that a fix for this is to execute the drag and drop in its own thread, and then update the UI. I read this article here
http://msdn.microsoft.com/en-us/library/ms741870.aspx
I am not sure if this is what I am looking to do, but It sounds like what I need.
Is there another fix around this?
Here is the code that I need to execute.
private void FieldItemGrid_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (_isDown)
{
if ((_isDragging == false))
{
/*Add Adorner to Item that is being dragged*/
DragStarted(e.GetPosition(this));
}
if (_selectedElement != null)
{
/*Begin Drag Operation*/
DragDrop.DoDragDrop(_selectedElement, _selectedElement, DragDropEffects.Move);
}
/*The following code is not executed until the dragged item is released*/
if (_isDragging)
{
/*Update Current Position of Mouse to update adorner position*/
DragMoved(e.GetPosition(this));
}
}
}