Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Handle Double Click

$
0
0
I am currently listening to void OnMouseLeftButtonDown(MouseButtonEventArgs e). I want to handle clicks and double clicks in there. I wish to execute a custom logic lets called it logic1 per click and another different custom logic lets call it logic2 per double click. However it seems the method is being called twice when I double click. First time with ClickCount 1 and second time with the ClickCount 2. Therefore logic1 is always executed.

How to handle only double clicks without having logic1 executed again?

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
  if (e.ClickCount > 1)
  {
   // logic2
  }
  else
  {
    // logic1
  }
}


Viewing all articles
Browse latest Browse all 18858

Trending Articles