首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MouseRightButtonDown应该与EventToCommand合作吗?

MouseRightButtonDown应该与EventToCommand合作吗?
EN

Stack Overflow用户
提问于 2014-03-18 15:21:25
回答 1查看 569关注 0票数 0

预期RightMouseDownEvent将与EventToCommand一起工作吗?

我可以将命令绑定到PreviewMouseRightUp和PreviewMouseRightDown,但是MouseRightButtonDown什么也不做。我是不是用错了事件名称--有那么简单吗?

在xaml中--我将两个事件绑定到同一个处理程序--只有一个工作(Preview...Up)。我依次评论每一个,但只有预览有效。

有什么想法?谢谢!

代码语言:javascript
复制
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                <cmd:EventToCommand Command="{Binding SetActivePaneCommand}"    CommandParameter="{Binding PaneOne}" PassEventArgsToCommand="False" />
                <cmd:EventToCommand Command="{Binding ListSelectionChangedCommand}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
                <i:EventTrigger EventName="MouseRightButtonDown">
                    <cmd:EventToCommand Command="{Binding PreviewMouseRightButtonUpCommand}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
                <i:EventTrigger EventName="PreviewMouseRightButtonUp">
                    <cmd:EventToCommand Command="{Binding PreviewMouseRightButtonUpCommand}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-18 15:34:32

一些控件处理MouseRightButtonDown事件,不让它传播(例如,MenuItem)。如果您正在调用一个代码背后的方法,而不是使用触发器,那么您可以很容易地测试它,并查看在该方法中是否会达到一个断点。

在xaml中:

代码语言:javascript
复制
    MouseRightButtonDown="UIElement_OnMouseRightButtonDown"

在后面的代码中:

代码语言:javascript
复制
    private void UIElement_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
    { }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22483662

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档