Combobox MVVM绑定并设置选中
MVVM绑定Combobox,代码如下
<ComboBox ItemsSource="{Binding TaskType,Mode=TwoWay}"
DisplayMemberPath="DisPlayName"
SelectedItem="{Binding Path=DataSource.SelectedTaskType,Mode=TwoWay}"
Width="80" x:Name="cb_tasktype" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<TriggerActions:MapEventToCommand Command="{Binding SelectTaskTypeChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>