Tag: WPF/DataGrid/DataGridColumn
DataGridComboBoxでElementStyleやEditingElementStyleを指定し、かつIsSynchronizedWithCurrentItem=Trueを使うと同列の他の行の表示がみだれるのでやめたほうがよいっぽい。
<DataGridComboBoxColumn Width="*" Header="変数の型"> <DataGridComboBoxColumn.ElementStyle> <Style TargetType="ComboBox"> <Setter Property="ItemsSource" Value="{Binding Path=Types}"/> <!-- これ --> <Setter Property="IsSynchronizedWithCurrentItem" Value="True"/> <Setter Property="DisplayMemberPath" Value="Label"/> <Setter Property="IsReadOnly" Value="True"/> <Setter Property="SelectedItem" Value="{Binding Type}"/> </Style> </DataGridComboBoxColumn.ElementStyle> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType="ComboBox"> <Setter Property="ItemsSource" Value="{Binding Path=Types}"/> <!-- これ --> <Setter Property="IsSynchronizedWithCurrentItem" Value="True"/> <Setter Property="DisplayMemberPath" Value="Label"/> <Setter Property="SelectedItem" Value="{Binding Type}"/> </Style> </DataGridComboBoxColumn.EditingElementStyle> </DataGridComboBoxColumn>