Distinguish between mouse doubleclick and mouse click in wpf

▼魔方 西西 提交于 2019-12-01 03:14:31

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

Sorry if I misunderstood your question.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!