我在数据模板中有带有复选框的组合框。Combobox ItemSource 属性与 ViewModel 中的集合绑定。我想让一个特定的复选框默认选中。我怎样才能做到这一点?
<ComboBox Grid.Column="1"
ItemsSource="{Binding MyCollection, Mode=OneWay}"
Style="{StaticResource MyComboboxStyle}"
Margin="5"
MinWidth="120">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext.MyCheckedCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
Content="{Binding}"
IsChecked="false"
VerticalAlignment="Center"
Margin="3"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>