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.
EDIT: I include the axml of the button:
<StackPanel Height="Auto" HorizontalAlignment="Left" Margin="548,0,0,0" Name="stpBotnoesBasicos" VerticalAlignment="Top" Width="Auto">
<Button Content="Buscar" Height="23" Name="btn01" Width="75">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding MouseSingleClickCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseDoubleClick">
<cmd:EventToCommand Command="{Binding MouseDoubleClickCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Stackpannel>