WPF DataGridTemplateColumn combobox updating all rows
c#, combobox, datagridtemplatecolumn, wpf, xaml
Solution
Apologies for the duplicates but after a few hours of guessing because there isn't enough material on the web for this kinda stuff, the solution is:
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Source={StaticResource DeploymentTypeEnum}}"
SelectedItem="{Binding DeploymentType}"
**IsSynchronizedWithCurrentItem="false**">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
`IsSynchronizedWithCurrentItem` - does what it says on the tin. However, when you select an item, the current one will disappear but at least it won't update all rows.
Problem
I have this XAML that selects a value from a combobox that the ItemSource is a Enum. The tutorial I used is: http://www.c-sharpcorner.com/uploadfile/dpatra/combobox-in-datagrid-in-wpf/ ``` <DataGrid x:Name="dgProductItem" ItemsSource="{Binding ProductVersion.ProductItems}" <DataGridTemplateColumn Header="Deployment Type" Width="120"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding DeploymentType}"></TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Source={StaticResource DeploymentTypeEnum}}" SelectedItem="{Binding DeploymentType}"> </ComboBox> </DataTemplate> </DataGridTemplateColumn.CellEditingTemplate> ``` However when I change a value from one row, it will update all the rows. Does anyone know why this is? Edit: if I just change one row, it will only update that row, but when I go to change a different row, that row I just changed will also change the previous one.. Cheers