Пример #1
0
 /// <summary>
 /// Occurs when the left mouse button is released.
 /// </summary>
 /// <param name="sender">Drag source.</param>
 /// <param name="e">MouseButtonEventArgs</param>
 private static void DragSourcePreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (s_DragController != null)
     {
         s_DragController.CancelDrag();
         s_DragController = null;
     }
 }
Пример #2
0
 /// <summary>
 /// Occurs when the left mouse button is clicked over a drag source.
 /// </summary>
 /// <param name="sender">Drag source.</param>
 /// <param name="e">MouseButtonEventArgs</param>
 private static void DragSourcePreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (s_DragController == null && (Mouse.Captured == null || Mouse.Captured == sender))
     {
         var element = sender as UIElement;
         if (element != null)
         {
             var dragElement = e.OriginalSource as UIElement;
             if (dragElement != null)
             {
                 s_DragController                         = GetDragController(element) ?? new DragController();
                 s_DragController.DragSource              = element;
                 s_DragController.StartPosition           = element.RealMousePosition();//e.GetPosition (element);
                 s_DragController.OriginalDragElement     = dragElement;
                 s_DragController.OriginalDragElementType = dragElement.GetType().ToString();
                 s_DragController.DragCompleted          += delegate { s_DragController = null; };
             }
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Sets the drag controller for a drag and drop operation.
 /// </summary>
 /// <param name="target">UI Element to set controller for.</param>
 /// <param name="value">Drag controller to use.</param>
 public static void SetDragController(UIElement target, DragController value)
 {
     target.SetValue(DragControllerProperty, value);
 }