Completed
Last Updated: 19 Apr 2022 06:45 by ADMIN
Release LIB 2022.1.425 (25 April 2022)
Martin Ivanov
Created on: 12 Apr 2022 10:34
Category: AutoSuggestBox
Type: Bug Report
1
AutoSuggestBox: No results are displayed if ItemsSource is assigned after the drop down has been opened

If the drop down get opened (which usually happens on text changed) before the ItemsSource is assigned, the no results presenter is never replaced with the list of results after the ItemsSource is set. This may happen if you delay the ItemsSource settings. A possible scenario is if you fetch your data from a service or using another type of async approach where the ItemsSource is assigned few moments after the TextChanged event was fired.

To work this around, you can manually update the Visibility of the items host or re-open the drop down after the ItemsSource is assigned. For example, you can create a custom RadAutoSuggestBox and override its OnPropertyChanged method. This will allow you to update the items host visibility on ItemsSource changed.

public class CustomAutoSuggestBox : RadAutoSuggestBox
{
	protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
	{
		base.OnPropertyChanged(e);
		if (e.Property.Name == "ItemsSource")
		{
			var listBox = (RadListBox)GetTemplateChild("PART_ItemsHost");
			listBox.Visibility = listBox.Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
		}
	}
}

0 comments