0
我需要将MouseBinding
添加到ListBoxItems
的InputBindings
。我知道如何在xaml中做到这一点。如何以编程方式绑定到模板中的输入绑定
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Border x:Name="MyBorder" ...>
<Border.InputBindings>
<MouseBinding MouseAction="LeftClick"
Command="{Binding SomeCommand}"/>
</Border.InputBindings>
</Border>
</Grid>
...
</ControlTemplate>
但我需要知道如何在代码隐藏中编写上述代码。无论如何要这样做?
你想获得一个EventArgs而点击这个ListBoxItem? –
我需要将命令绑定到ListBoxItem的鼠标单击事件。 – user3530012