Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get repeated double-clicks without WPF changing some to triple-clicks?
    primarykey
    data
    text
    <p>I've got a listbox in my WPF app, and when the user double-clicks on an item, I change the contents of the list (something like directory navigation). In some cases, it makes sense to double-click, and then immediately double-click again, because you know what's going to appear in that same spot. You would expect that you could do that by just clicking four times in rapid succession (which ought to mean "two double-clicks").</p> <p><em>But that doesn't work.</em> If you click rapid-fire enough, it's not until the fifth or sixth click before WPF will send another double-click event!</p> <p>It looks like WPF has built-in support for triple-clicks, and sometimes even more, if you click fast enough. I ran a quick example to confirm this:</p> <pre><code>&lt;ListBox PreviewMouseLeftButtonDown="ListBox_PreviewMouseLeftButtonDown"/&gt; private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Trace.WriteLine("ClickCount = " + e.ClickCount); } </code></pre> <p>When I ran it, and clicked rapid-fire, I got output like this:</p> <pre><code>ClickCount = 1 ClickCount = 2 ClickCount = 3 ClickCount = 1 ClickCount = 2 ClickCount = 3 ClickCount = 4 ClickCount = 1 ClickCount = 2 ClickCount = 3 </code></pre> <p>Sometimes it counted up to 3 and then reset; sometimes it counted up to 4 before it reset. I couldn't get it to go up to 5.</p> <p>But then I went into Control Panel > Mouse, and changed my double-click speed to the slowest possible setting. Then I was reliably able to get it to count up to 10 before it reset, and up to 11 or 12 if I was really booking it. So apparently it's all about how fast you can click before your system-configured "double-click" interval. If you click more times before that interval has elapsed, you get a "triple-click" or a "quadruple-click" or more.</p> <p>But I don't <em>want</em> triple-clicks or quadruple-clicks -- especially not if they're impossible to get with certain double-click configurations. I want every other click to be a double-click event (as long as they're in rapid succession, the mouse hasn't moved more than the threshold amount, etc.)</p> <p>Is there any way I can get WPF to give me normal double-click events (an event for every other click) when I'm clicking rapid-fire?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload