Completed
Last Updated: 13 Aug 2021 12:44 by ADMIN
Release LIB 2021.2.816 (16 Aug 2021)
Martin Ivanov
Created on: 04 Aug 2021 11:13
Category: ComboBox
Type: Bug Report
1
ComboBox: NullReferenceException when the Text becomes null in multi-selection scenario

NullReferenceException appears when the multiple selection is enabled, items are selected and the Text property of the RadComboBox control becomes null.

To resolve this, you can override the OnTextChanged method of RadComboBox and replace the null value with an empty string.

public class CustomRadComboBox : RadComboBox
{
	protected override void OnTextChanged(string oldValue, string newValue)
	{
		if (string.IsNullOrEmpty(newValue))
		{
			newValue = string.Empty;
			Dispatcher.BeginInvoke(new Action(() =>
			{
					SelectedItems.Clear();
			}));
		}
		base.OnTextChanged(oldValue, newValue);
	}
}

0 comments