views:

142

answers:

1

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?

A: 

I have not yet resolved

however I have defined a simple project that show the problem.

You can download it from this link: http://pollosky.it/wp-content/uploads/2009/12/ObjectProviderTest.zip

Try to selectvalue from the second cell of the first row and then go to the second row. The value of property of first row is cleared!

How can I do?

LukePet
Anyone? Any informations or opinions about this problem is useful for me...what do you think about?
LukePet