Distinguish between mouse doubleclick and mouse click in wpf

前端 未结 2 1235
甜味超标
甜味超标 2021-01-11 12:08

In my WPF application , I am using ListView GridView, and I implemented a functionality that is associated to mouse double click. Is there a way, or a control that distingui

相关标签:
2条回答
  • 2021-01-11 12:38

    It seems you just add the MouseDoubleClick= attribute. Check these links out:

    • WPF Tutorial - Getting the DoubleClick Event
    • MouseDoubleClick MSDN Documentation
    • Detect mouse double click in WPF - Channel9

    Sorry if I misunderstood your question.

    0 讨论(0)
  • 2021-01-11 12:51

    Handling the double click event for controls that present the MouseDoubleClick event is no trick. Handling double click for other controls involves inspecting the ClickCount property of the MouseButtonEventArgs.

    So, for instance, your XAML might look something like this:

    <SomeControl  MouseDown="MyMouseDownHandler">
        ...
    </SomeControl>
    

    ... and your code behind like this:

    private void MyMouseDownHandler(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount == 2)
        {
            // Handle double-click
        }
    }
    

    Here's a page that provides a somewhat more detailed example.

    0 讨论(0)
提交回复
热议问题