我正在尝试使用 RoutingCommand 绑定 ComboBox 的 SelectionChanged 事件(与绑定按钮的命令相同)。但无法实现。我不喜欢使用任何第三方控件或在属性中编写代码。
			
			2817 次
		
2 回答
            1        
        
		
您确定需要 SelectionChanged 事件吗?只需绑定
SelectedItem="{Binding Path=ComboSelected, Mode=TwoWay}"
其中 ComboSelected 是您的 ViewModel 的属性。并在 ComboSelected 属性的设置器中执行您需要的操作。
于 2012-04-12T08:13:45.520   回答
    
    
            1        
        
		
你可以使用System.Windows.Interactivitydll。
代码将是这样的:
<UserControl
 ...
 xmlns:ei="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
 ...>    
 ...
 <Combobox>
    <ei:Interaction.Triggers>
       <ei:EventTrigger EventName="SelectionChanged">
           <ei:InvokeCommandAction Command="{Binding Command}"/>
       </ei:EventTrigger>
    </ei:Interaction.Triggers>
 </Combobox>
 ...    
</UserControl>
于 2012-04-12T08:25:14.233   回答