7

ListBoxItemのそれぞれに右クリックと左クリックのコマンドを追加したいと思いますStyle。これは可能ですか?

<Style TargetType="{x:Type ListBoxItem}">
    <Setter Property="InputBindings">
        <Setter.Value>
            <MouseBinding Command="{x:Static View:Commands.AddItem}"
                          MouseAction="LeftClick"/>
            <MouseBinding Command="{x:Static View:Commands.RemoveItem}"
                          MouseAction="RightClick"/>
        </Setter.Value>
    </Setter>
</Style>
4

1 に答える 1

2

私は当初望んでいたことを達成する方法を見つけることができませんでした。コマンドの代わりにイベントを使用することになりました。

<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="AssignItem"/>
<EventSetter Event="PreviewMouseRightButtonDown" Handler="RemoveItem"/>
</Style>
于 2010-01-05T22:17:38.097 に答える