0

RightMouseDownEvent 是否有望与 EventToCommand 一起使用?

我可以将命令与 PreviewMouseRightUp 和 PreviewMouseRightDown 绑定,但 MouseRightButtonDown 什么也不做。我是否使用了错误的事件名称——就这么简单吗?

在 xaml 中——我将两个事件绑定到同一个处理程序——只有一个有效(预览...向上)。我依次注释掉每个,但只有预览有效。

想法?谢谢!

            <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>
4

1 回答 1

1

一些控件处理 MouseRightButtonDown 事件并且不让它传播(例如 MenuItem)。如果您正在调用代码隐藏方法而不是使用触发器,则可以轻松测试这一点,并查看您是否会到达该方法中的断点。

在您的 xaml 中:

    MouseRightButtonDown="UIElement_OnMouseRightButtonDown"

在您后面的代码中:

    private void UIElement_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
    { }
于 2014-03-18T15:34:32.287 回答