I have a DataGrid
with a column that looks like:
<DataGridTemplateColumn Header="Thing">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ThingName}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<myui:AutoCombo ItemsSource="{Binding Things}"
SelectedValue="{Binding ThingId, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ThingName"
SelectedValuePath="ThingId"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
myui:AutoCombo
is a very minimal extension of System.Windows.Controls.ComboBox
, only changing its Items.Filter
under certain circumstances.
Things
is an ObservableCollection
. Both the cell template and the cell editing template display correctly, and populate correctly on form load. Additionally, when the SelectedValue
property is changed by the user, ThingId
is correctly changed.
However, if some code-behind changes the contents of Things
, the dropdown is not re-populated. I wonder why, and how to get this to work?