After upgrade to .NET Framework 4.7.2 I noticed a strange behavior of the ComboBox when it is into a DataGridTemplateColumn.CellEditingTemplate.
<DataGrid
IsReadOnly="False"
ItemsSource="{Binding Path=Items, Mode=OneWay}">
<DataGrid.Columns>
<DataGridTemplateColumn
Header="Test"
IsReadOnly="False"
Width="70">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
VerticalAlignment="Center"
TextAlignment="Left"
Text="{Binding Path=Id, Mode=OneWay}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox
Name="cmbTest"
DisplayMemberPath=""
HorizontalAlignment="Stretch"
IsEditable="True"
IsEnabled="True"
IsReadOnly="False"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Path=Items2, Mode=OneWay}"
Margin="0"
SelectedItem="{x:Null}"
SelectedValue="{x:Null}"
SelectedValuePath=""
Text=""
VerticalAlignment="Center"
Visibility="Visible"
SelectionChanged="cmbTest_SelectionChanged">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Before upgrade, event "cmbTest_SelectionChanged" was raised only when I change the SelectedItem, but now (after 4.7.2. upgrade) "cmbTest_SelectionChanged" is raised (with "null" SelectedItem!) also when I exit by cell editing...and this is a problem for my application.
How can I avoid this issue?
UPDATE 16/06/2018: I have discovered that the issue occurs only when the bind list to the ComboBox (Items2) is a property of the SelectedItem. If I bind the list to external datacontext (FindAncestor...) it seems works properly.