I am binding a left click gesture to a WPF button, expecting that it only fires when the mouse is clicked (MouseDown+MouseUp). However, it appears to fire immediately upon pressing the mouse button down (without releasing).
- Is this the correct way to bind to a left click?
- How do I differentiate between a click and a press in the event handler?
Sample code:
public partial class WpfTest : UserControl
{
// Gesture for clicking
public static MouseGesture MouseClickGesture = new MouseGesture(MouseAction.LeftClick);
// Logon command/gesture binding
public static RoutedUICommand LogonCommand = new RoutedUICommand();
public static MouseBinding LogonClickBinding = new MouseBinding(LogonCommand, MouseClickGesture);
public WpfTest()
{
InitializeComponent();
CommandBindings.Add(new CommandBinding(LogonCommand, LogonClicked));
Logon.InputBindings.Add(LogonClickBinding);
}
private void LogonClicked(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("LogonClicked");
}
}