我知道这个问题以前已经被问过。我想确认是否有任何新的巧妙解决方案。是否有更好的方法可以绑定DataGridComboBoxColumn
的SelectedIndex
? 这是我搜索了很多后得到的绑定方式:
<!-- This is a little ridiculous -->
<DataGridComboBoxColumn Header="Batch Type"
ItemsSource="{Binding Source={StaticResource methodOfPaymentItemsProvider}}">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="SelectedIndex"
Value="{Binding MethodOfPayment,
UpdateSourceTrigger=PropertyChanged}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="SelectedIndex"
Value="{Binding MethodOfPayment,
UpdateSourceTrigger=PropertyChanged}" />
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>