Exemple #1
0
       private void FinalizePreviewControlMouseUp()
       {
           _dragDropContainer.Children.Remove(_dragDropPreviewControl);
           _dragDropContainer.PreviewMouseMove -= DragDropContainer_PreviewMouseMove;
           _dragDropContainer.PreviewMouseUp -= DragDropContainer_PreviewMouseUp;
 
           if (_dragDropPreviewControl != null)
           {
               _dragDropPreviewControl.ReleaseMouseCapture();
           }
           _dragDropPreviewControl = null;
           Mouse.OverrideCursor = null;
       }
Exemple #2
0
 public static void SetDragDropPreviewControl(DependencyObject element, DragDropPreviewBase value)
 {
     element.SetValue(DragDropPreviewControlProperty, value);
 }
Exemple #3
0
        private void DragSource_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (_mouseCaptured || _dragDropPreviewControlDataContext == null)
            {
                return;
            }

            if (DragDrop.IsMovementBigEnough(_initialMousePosition, e.GetPosition(_topWindow)) == false)
            {
                return;
            }

            _dragDropPreviewControl = (DragDropPreviewBase) GetDragDropPreviewControl(sender as DependencyObject);
            _dragDropPreviewControl.DataContext = _dragDropPreviewControlDataContext;
            _dragDropPreviewControl.Opacity = 0.7;

            _dragDropContainer.Children.Add(_dragDropPreviewControl);
            _mouseCaptured = Mouse.Capture(_dragDropPreviewControl);

            Mouse.OverrideCursor = Cursors.Hand;

            Canvas.SetLeft(_dragDropPreviewControl, _initialMousePosition.X - 20);
            Canvas.SetTop(_dragDropPreviewControl, _initialMousePosition.Y - 15);

            _dragDropContainer.PreviewMouseMove += DragDropContainer_PreviewMouseMove;
            _dragDropContainer.PreviewMouseUp += DragDropContainer_PreviewMouseUp;
        }