I have a problem with a edit templete of cell in a WPF datagrid (WPF Toolkit). The template is builded with a ComboBox and the ItemsSource of ComboBox are loaded at runtime.
This is the mean code...
<ObjectDataProvider x:Key="dataValuesProvider" MethodName="GetValues" />
<toolkit:DataGrid
ItemsSource="{Binding Path=MyItems}">
<toolkit:DataGridTemplateColumn
Header="Property1">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Property1, ValidatesOnDataErrors=true}"/>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
<toolkit:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox
SelectedValue="{Binding Path=Property1, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
IsEditable="True"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource dataValuesProvider}, Mode=OneWay}"
/>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellEditingTemplate>
</toolkit:DataGridTemplateColumn></toolkit:DataGrid>
Now, I have this problem.
I have to update the dataValuesProvider with different value on each rows. Then I have insert a reset of dataValuesProvider (dataValuesProvider=null) on selectionchanged event of datagrid.
(The dataValuesProvider will load after a input on a specific cell of the selected row).
This is the problem: when I reset the dataValuesProvider (on selectionchanged of a new row) it's modified the SelectedValue of ComboBox and the Property1 of previous row is cleared.
I think that there is this behavior becouse the editing template of cell not update the binding associations until I edit the cell. It's right?
How can I do to avoid this problem?