8

I am trying to fetch a double click from the user on a canvas. I am using the previewmousedown event for this, but it isn't working properly.

The function is as following:

    void DrawCanvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {

        /* Check if it is a double click */
        if(e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
        {
           //do double click actions
        }
        else
        {
           //do single click actions
        }
        e.Handled = true;
    }

I have tried to move it to the previewmouseup function as well, but the clickcount stays on 1.

Anyone an idea why the clickcount doesn't go up?

Loktar
  • 34,764
  • 7
  • 90
  • 104

1 Answers1

3

Instead of using PreviewMouseLeftButtonDown Event, use MouseLeftButtonDownEvent to overcome this Problem.