vain0x / DotNetKit.Wpf.AutoCompleteComboBox

ComboBox with filtering (auto-complete) for WPF
MIT License
71 stars 26 forks source link

Fix null reference inside OnTextChanged timer #14

Closed kvpt closed 4 years ago

kvpt commented 4 years ago

Today I got this stacktrace in my log :

at IEnumerable<TResult> System.Linq.Enumerable.Cast<TResult>(IEnumerable source)
at void DotNetKit.Windows.Controls.AutoCompleteComboBox.UpdateSuggestionList()
at object System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
at void System.Windows.Threading.DispatcherOperation.InvokeImpl()

I found that it's caused because my app load ItemSource asynchronously and if a user enter text before the data has been loaded, the ItemSource is null and it's cause this. The application doesn't crash because this code is run by the dispatcher, but the control is now in some sort of bad state and remain empty even after the ItemSource is populated.

vain0x commented 4 years ago

Thank you!