#710 – DoDragDrop Is a Blocking Call

When you initiate a drag-and-drop operation by calling DragDrop.DoDragDrop, control will not return from the DoDragDrop method until the drag-and-drop operation has completed.

        private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DataObject data = new DataObject(DataFormats.Text, ((Label)e.Source).Content);

            DragDrop.DoDragDrop((DependencyObject)e.Source, data, DragDropEffects.Copy);

            // Not called until drag-and-drop is done
            ((Label)e.Source).Content = "DragDrop done";
        }

        private void Label_Drop(object sender, DragEventArgs e)
        {
            ((Label)e.Source).Content = (string)e.Data.GetData(DataFormats.Text);
        }

710-001
710-002

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #710 – DoDragDrop Is a Blocking Call

  1. Pingback: Dew Drop – December 12, 2012 (#1,461) | Alvin Ashcraft's Morning Dew

Leave a comment