Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top