문제

I have a Datagrid and DataGridTemplateColumn which is ComboBox

<DataTemplate x:Key="ComboBoxPackagingType">
  <ComboBox SelectedItem="{Binding   PackagingType.SelectedItem, Mode=TwoWay}" ItemsSource="{Binding PackagingType.ItemsSource}"/>
</DataTemplate>

...

<DataGridTemplateColumn CellTemplate="{StaticResource ComboBoxPackagingType}"/>

The SelectedItem is never changing the value after selecting an Item from list. I set the breakpoints on both get and set functions and it is stopping on get function after changing the ItemSource of my DataGrid but never on the set function after selecting an Item from list.

Why?

도움이 되었습니까?

해결책

Try adding UpdateSourceTrigger=PropertyChanged to the binding of your ComboBox's selected item like so:

<DataTemplate x:Key="ComboBoxPackagingType">
  <ComboBox SelectedItem="{Binding PackagingType.SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding PackagingType.ItemsSource}"/>
</DataTemplate>

This worked for me.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top