在MVVM中实现ComboBox SelectionChanged

添加命名空间

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

添加引用

System.Windows.Interactivity

具体如下:

<ComboBox x:Name="fileComboBox" Margin="5"  Width="130"
ToolTip
="Flag"
ItemsSource
="{Binding FileList, Mode=TwoWay}" SelectedIndex="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionChangedCommand}"
CommandParameter
="{Binding SelectedItems, ElementName=fileComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
posted @ 2011-08-30 16:35  黎明即起  阅读(656)  评论(0编辑  收藏  举报