7

我想ListBoxItemStyle. 这可能吗?

<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 回答