为什么 WPF 边框控件没有 mousedoubleclick 事件? [英] Why doesn't WPF border control have a mousedoubleclick event?

查看:45
本文介绍了为什么 WPF 边框控件没有 mousedoubleclick 事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 WPF 边框控件没有 mousedoubleclick 事件?我有一个 ItemsControl,其中包含一些用于 DataTemplate 的布局内容.我想处理双击事件以弹出详细信息对话框,但是我的布局容器边框似乎没有公开该事件.

Why doesn't WPF border control have a mousedoubleclick event? I have a ItemsControl with some layout stuff in it for a DataTemplate. I want to handle the double click event to pop up a details dialog, but the border, my layout container, doesn't appear to expose the event.

关于如何获得双击事件或重新编写 xaml 以使其成为可能的任何建议?

Any suggestions on how to either get at the double click event, or rework the xaml to make it possible?

推荐答案

只需使用 InputBindings.

Just use InputBindings.

<Border>
    <Border.InputBindings>
        <MouseBinding MouseAction="LeftDoubleClick" Command="..."/>
    </Border.InputBindings>
</Border>

一般情况下;如果不在 WPF 中开发控件,请避免使用事件.通常,使用基于事件的代码是 MVVM 模式中断的强烈迹象.

In general; avoid using events if not developing controls in WPF. Usually the usage of code behind based events is a strong indication for a MVVM Pattern break.

这篇关于为什么 WPF 边框控件没有 mousedoubleclick 事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆