通常,对于文本框,我使用输入绑定将其绑定到视图模型中的命令。我是这样做的:
<TextBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding MyCommand}"/>
</TextBox.InputBindings>
如果我在文本框中设置它,它就可以工作,但如果我在组合框中设置,它就不工作。
<ComboBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding MyCommand}"/>
</ComboBox.InputBindings>
如何绑定多臂点击?
谢谢。
您可以使用Microsoft.Xaml.Behaviors.Wpf中的交互触发器:
<ComboBox xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding MyCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>