I'd like to handle both MouseLeftButtonUp
and MouseDoubleClick
events on Image
. I used galasoft mvvm light
library for EventToCommand
. But, MouseDoubleClick
is not called. Actually, it is called, but very rare. Why does this happen and how to fix it?
<ContentControl>
<Image Source = "{Binding Img}" Stretch="Fill" />
<i:Interaction.Triggers>
<i:EventTrigger EventName = "MouseLeftButtonUp" >
< cmd:EventToCommand Command = "{Binding MouseUpCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName = "MouseDoubleClick" >
< cmd:EventToCommand Command = "{Binding DoubleClickCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ContentControl>
private ICommand _doubleClickCommand;
public ICommand DoubleClickCommand
{
get
{
if (_doubleClickCommand== null)
{
_doubleClickCommand=new RelayCommand<MouseEventArgs>(DoubleClikcFunc);
}
return _doubleClickCommand;
}
}
private ICommand _mouseUpCommand;
public ICommand MouseUpCommand
{
get
{
if (_mouseUpCommand== null)
{
_mouseUpCommand= new RelayCommand<MouseEventArgs>(MouseUpFunc);
}
return _mouseUpCommand;
}
}
private void MouseUpFunc(MouseEventArgs e)
{
Points.Add(e.GetPosition((IInputElement)e.Source));
}
private void DoubleClikcFunc(MouseEventArgs e)
{
Points.Add(MaskPoints[0]);
}