Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single click and double click on the same Image control(wpf)

Tags:

click

double

wpf

I am trying to have different behaviours when single clicking and double clicking the wpf Image control. Unfortunately the single click is fired first, so the double click is ignored.

like image 258
phm Avatar asked Dec 12 '22 20:12

phm


2 Answers

If you use the MouseDown event instead it has a property in the EventArgs for ClickCount. This allows you to know how many times the user has clicked on the control within the system's double click time span.

You can probably use this to implement your own logic for deciding between a double and single click.

like image 177
Martin Harris Avatar answered Dec 15 '22 10:12

Martin Harris


You can check double clicks using ClickCount property in the event args.

         if(e.ClickCount == 2)
         {
          // Do something here
         }

PS: If you are using MouseDown or MouseClick event make sure you are checking for left button double clicks.You can do this like :

           if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
           { 
           // Do Something here
           }
like image 38
kiran Avatar answered Dec 15 '22 08:12

kiran