I got the stack trace below reported from a customer. I don\'t know how to reproduce this. My WPF application has a fair number of ComboBoxes; I\'m not sure how to determine
I got the same error with similar code to what maiksaray shared. For me, the NullReferenceException at CoerceIsSelectionBoxHighlighted only happened on Windows 10, not on my Windows 7 dev machine. It only happened the first time the combo box was clicked to open.
In my case, I was programmatically opening and closing the combobox when the view loaded:
public MyView()
{
InitializeComponent();
Loaded += OnLoaded;
}
private void comboBox1_DropDownOpened(object sender, EventArgs e)
{
comboBox1.ItemsSource = MyClass.GetComboBoxList();
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
comboBox1.IsDropDownOpen = true;
comboBox1.IsDropDownOpen = false;
}
I was doing this as the workaround to another problem, described here: http://blog.elgaard.com/2009/09/03/wpf-making-combo-box-items-disabled-also-when-accessed-using-the-keyboard/
The error happened after DevicesComboBox_DropDownOpened completed. However, it only happened with the OnLoaded code present. If I commented out Loaded += OnLoaded, then I didn't get the error.
The solution for me was to simply avoid programmatically opening and closing the ComboBox.