private void CanvasBoard_Drop(object sender, DragEventArgs e) { if (sender != null) { var classOutline = new ClassBoxControl(100, 150); Canvas.SetLeft(classOutline, e.GetPosition(CanvasBoard).X); Canvas.SetTop(classOutline, e.GetPosition(CanvasBoard).Y); CanvasBoard.Children.Add(classOutline); } }
private void CanvasBoard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var result = VisualTreeHelper.HitTest(CanvasBoard, e.GetPosition(CanvasBoard)); DependencyObject obj = VisualTreeHelper.GetParent(result.VisualHit); while (obj != null) { if (obj is ClassBoxControl) { _currentControl = obj as ClassBoxControl; if (_currentControl.TemplatedParent != null) { _currentControl = _currentControl.TemplatedParent as ClassBoxControl; } break; } else { obj = VisualTreeHelper.GetParent(obj); } } }
private void CanvasBoard_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { _currentControl = null; }