0

RightMouseDownEvent は EventToCommand で動作すると予想されますか?

Command を PreviewMouseRightUp と PreviewMouseRightDown にバインドできますが、MouseRightButtonDown は何もしません。間違ったイベント名を使用していますか?それは簡単ですか?

xaml では、両方のイベントが同じハンドラーにバインドされています。1 つだけが機能します (Preview...Up)。それぞれを順番にコメントアウトしますが、プレビューのみが機能します。

考え?ありがとう!

            <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 に答える