Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinguish between mouse doubleclick and mouse click in wpf

In my WPF application , I am using ListView GridView, and I implemented a functionality that is associated to mouse double click. Is there a way, or a control that distinguish between the mouse double click and mouse click?

I used a button, and implemented an event for mousedoubleclick, but the click event is still triggering

Thanks for help

like image 625
Ghassan Karwchan Avatar asked Oct 27 '09 16:10

Ghassan Karwchan


People also ask

What is the difference between click and Doubleclick?

Typically, a single click initiates a user interface action and a double-click extends the action. For example, one click usually selects an item, and a double-click edits the selected item.

What is double clicking mouse?

1. Double-click is a term used to describe the process of quickly pressing a mouse button twice while keeping it still. In most cases, a double-click is with the left mouse button and is used to open or execute a file, folder, or software program.

How do I know if double-click?

To detect double clicks with JavaScript you can use the event listener dblclick . The dblclick event is supported in all modern browsers for desktop/laptops, even Internet Explorer 11.

What is single click in mouse?

If you want to make it easier to click and select things in Windows 10, try using the single click option. The double-click has long been a convention for launching applications or opening files or folders in Windows. The single click, meanwhile, is used for selecting items.


1 Answers

Handling the double click event for controls that present the MouseDoubleClick event is no trick. Handling double click for other controls involves inspecting the ClickCount property of the MouseButtonEventArgs.

So, for instance, your XAML might look something like this:

<SomeControl  MouseDown="MyMouseDownHandler">
    ...
</SomeControl>

... and your code behind like this:

private void MyMouseDownHandler(object sender, MouseButtonEventArgs e)
{
    if (e.ClickCount == 2)
    {
        // Handle double-click
    }
}

Here's a page that provides a somewhat more detailed example.

like image 157
mcwyrm Avatar answered Sep 22 '22 06:09

mcwyrm