C# MouseButtonEventArgs ClickCount - How do I separate what happens in one or two clicks?

Viewed 28

My goal is that if you click once on a TextBlock, it copies the text and if you click twice on it, it executes something else without copying the text.

I thought a switch would be handy, but it still copies the text when double-clicked.

private void Path_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (e.LeftButton == MouseButtonState.Pressed)
    {
        switch (e.ClickCount)
        {
            case 1:
                System.Windows.Clipboard.SetText(ViewModel.MainPath);
                break;
            case 2:
                StartProcess.Start(ViewModel.MainPath, true);
                break;
        }
    }
}
1 Answers
Related