private void CopyControl() { canvas = new Canvas(); mainWindow.Grid_Main.Children.Add(canvas); canvas.Width = mainWindow.Grid_Main.ActualWidth; canvas.Height = mainWindow.Grid_Main.ActualHeight; canvas.Margin = new Thickness(0, 0, 0, 0); dragControl = new DocumentControl(); dragControl.FilenameText = this.FilenameText; dragControl.FilePath = this.FilePath; dragControl.Width = this.Width; dragControl.Height = this.Height; dragControl.Opacity = 0.7; dragControl.AllowDrop = false; dragControl.IsHitTestVisible = false; //mainWindow.Grid_Main.Children.Add(docDragControl); canvas.Children.Add(dragControl); Point relativePoint = this.TransformToAncestor(mainWindow).Transform(new Point(0, 0)); Canvas.SetTop(dragControl, relativePoint.Y); Canvas.SetLeft(dragControl, relativePoint.X); }
// Fired from MouseMove when DoDragDrop returns result private void UserControl_MouseUp(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Released) { if (dragControl != null) { canvas.Children.Remove(dragControl); mainWindow.Grid_Main.Children.Remove(canvas); dragControl = null; canvas = null; } } }