void OnDrawDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { PART_Grid.CaptureMouse(); IsDragging = true; StartPosition = e.GetPosition(PART_Grid); Selection.Set(new Rect(StartPosition.X, StartPosition.Y, 0, 0)); } }
void OnDrawUp(object sender, MouseButtonEventArgs e) { IsDragging = false; if (PART_Grid.IsMouseCaptured) { PART_Grid.ReleaseMouseCapture(); } StartPosition = default(Point); OnSelected(Selection); if (ResetOnDrawn) { Selection.Set(new Rect(0, 0, 0, 0)); } }