2

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?

artos
  • 751
  • 1
  • 10
  • 25

1 Answers1

1

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.

bryan
  • 170
  • 3
  • 13
  • Great! Glad I could help. Please mark this as answered then? You can do so by clicking on the green tick next to my answer. – bryan Feb 08 '13 at 04:35