Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF Mouse
I searched MSDN for e.ClickCount, and it provieds the following eg.:
<textblock x:name="tb" text="" background="Black" foreground="White" />
and the code behind:
 public partial class Window1 : Window
         public Window1()
            this.tb.MouseDown += new MouseButtonEventHandler(tb_MouseDown);
        void tb_MouseDown(object sender, MouseButtonEventArgs e)
             // Checks the number of clicks. 
            if (e.ClickCount == 1)
                 // Single Click occurred.
                 this.tb.Text = "Single Click";
             if (e.ClickCount == 2)
                 // Double Click occurred.
                 this.tb.Text += "Double Click";
             if (e.ClickCount >= 3)
                 // Triple Click occurred.
                 this.tb.Text += "Triple Click";

But what I want to get is like this:
(1)When I click once at one time, then execute DoSomethingForClick(). This has no problem!

(2)When I click twice at one time, then only execute DoAnotherForDoubleClick(). NOT firstly execute DoSomethingForClick() and then execute DoAnotherForDoubleClick() like in the MSDN eg., because tb_MouseDown fired 2 times;

How can I do?
Posted 25-Sep-12 15:07pm
Edited 25-Sep-12 23:30pm
Sergey Alexandrovich Kryukov at 25-Sep-12 21:23pm
I'm sure you can do it, but why? Imagine the confusion of the user. Can you always distinguish it by yourself what it was: two separate clicks or a double click? I would rather review the conception of your UI and usability.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think your problem is caused by the system sending the following stream of messages for each 'double click' (check 'WM_LBUTTONDBLCLK' on msdn).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,240
3 George Jonsson 3,584
4 Gihan Liyanage 2,625

Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100