public void OnMouseButtonUp(object sender, MouseButtonEventArgs e) { e.Handled = true; ButtonState.End.PositionInformation = e; ButtonState.End.EventOrigin = sender; if (ButtonState.IsMouseDown) { ButtonState.SetSingleClick(); } else if (ButtonState.IsSingleClick) { ButtonState.SetDoubleClick(); } else if (ButtonState.IsDrag) { _timerDoubleClick.Stop(); _timerHeldClick.Stop(); if (ButtonDragReleased != null) { ButtonDragReleased(this, ButtonState.BuildEventArgs()); } ButtonState.Reset(); } else if (ButtonState.IsInactive) { _timerDoubleClick.Stop(); _timerHeldClick.Stop(); if (ButtonDragReleased != null) { MouseManagerEventArgs eventArgs = ButtonState.BuildEventArgs(); eventArgs.Start = eventArgs.End; ButtonDragReleased(this, eventArgs); } ButtonState.Reset(); } }