Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with DataTemplate and ObjectDataProvider refresh
    text
    copied!<p>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.</p> <p>This is the mean code...</p> <pre><code>&lt;ObjectDataProvider x:Key="dataValuesProvider" MethodName="GetValues" /&gt; &lt;toolkit:DataGrid ItemsSource="{Binding Path=MyItems}"&gt; &lt;toolkit:DataGridTemplateColumn Header="Property1"&gt; &lt;toolkit:DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text="{Binding Path=Property1, ValidatesOnDataErrors=true}"/&gt; &lt;/DataTemplate&gt; &lt;/toolkit:DataGridTemplateColumn.CellTemplate&gt; &lt;toolkit:DataGridTemplateColumn.CellEditingTemplate&gt; &lt;DataTemplate&gt; &lt;ComboBox SelectedValue="{Binding Path=Property1, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" IsEditable="True" IsSynchronizedWithCurrentItem="False" ItemsSource="{Binding Source={StaticResource dataValuesProvider}, Mode=OneWay}" /&gt; &lt;/DataTemplate&gt; &lt;/toolkit:DataGridTemplateColumn.CellEditingTemplate&gt; &lt;/toolkit:DataGridTemplateColumn&gt;&lt;/toolkit:DataGrid&gt; </code></pre> <p>Now, I have this problem. </p> <p>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.</p> <p>(The dataValuesProvider will load after a input on a specific cell of the selected row).</p> <p>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.</p> <p>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?</p> <p>How can I do to avoid this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload