0
我正在使用使用拖放功能的WPF應用程序。WPF拖放阻止操作
拖放操作是一種阻塞操作,在我的應用程序中有一些負面影響。我最近添加了一個裝飾器來顯示項目拖動。這個問題是,爲了做到這一點,我需要跟蹤鼠標的當前位置。當啓動拖放操作時,它會阻止進一步的執行,直到項目被刪除。
我已經讀過,解決這個問題的方法是在自己的線程中執行拖放操作,然後更新UI。我在這裏
http://msdn.microsoft.com/en-us/library/ms741870.aspx
閱讀這篇文章,我不知道這是否是我所期待的事情,但是這聽起來像我需要什麼。
有沒有另外解決這個問題?
這是我需要執行的代碼。
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));
}
}
}
謝謝你,我已經做了一些改變,但我無法看到裝飾器。我做了另一篇文章http://stackoverflow.com/questions/5019945/drag-adorner-not-updating-correctly-in-wpf-application你認爲你可以看看嗎? – TheJediCowboy 2011-02-16 17:37:09