the stopwatch is not stopped
I would like to control if the user do single click or double click when
is clicked with the mouse. So I use this code:
private void MouseSingleClickCommand(RoutedEventArgs e)
{
_dtMouseClick.Start();
}
private void MouseClick_Tick(object sender, System.EventArgs e)
{
_dtMouseClick.Stop();
//my one click code
}
private void MouseDoubleClickCommand(MouseButtonEventArgs e)
{
_dtMouseClick.Stop();
//code of the double click
}
_dt is a DispatcherTimer that is created in the constructor of the view
model:
_dtMouseClick =
new System.Windows.Threading.DispatcherTimer(
new TimeSpan(0, 0, 0, 0, 200),
System.Windows.Threading.DispatcherPriority.Background,
MouseClick_Tick,
System.Windows.Threading.Dispatcher.CurrentDispatcher);
However the code of one click is always executed because the dispatcher is
not stopped.
Why?.
Thanks.
No comments:
Post a Comment