Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:25:44+00:00 2026-05-24T20:25:44+00:00

I am binding a left click gesture to a WPF button, expecting that it

  • 0

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).

  1. Is this the correct way to bind to a left click?
  2. 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");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:25:45+00:00Added an answer on May 24, 2026 at 8:25 pm

    I would not use those bindings, for all i know you can not get a proper click from them (seriously, who designed this?). From what i’ve seen it is suprisingly hard to get an actual click on an arbitrary control. I would suggest you wrap a Button around whatever you want to be clickable and use the Button’s Command /Click-Event.

    Change the Button’s template to this to make it invisible:

    <ControlTemplate TargetType="{x:Type Button}">
        <ContentPresenter/>
    </ControlTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm playing around with WPF Binding and variables. Apparently one can only bind DependencyProperties.
1) Binding to The following populates a READ ONLY WinFrms grid: Dim query =
The Binding syntax, {Binding /} , works in WPF but does not work at
So i have a listbox: <ListBox x:Name=listbox HorizontalAlignment=Left Margin=8,8,0,8 Width=272 BorderBrush={x:Null} Background={x:Null} Foreground={x:Null} ItemsSource={Binding
How to open context menu on left click instead of right click in silverlight
While learning c# and wpf, i am trying to get grasp of data binding.
I am trying to get the absolute position (top and left) of a mouse
I want to just click a button create my object which is a form
So I have several comboboxes in my WPF application that don't change the selection
I would like to add a button to the combobox ItemTemplate, that allows the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.