No Results Found in .NET MAUI ComboBox (SfComboBox)
24 Apr 20254 minutes to read
When the entered item is not in the suggestion list, SfComboBox displays a text indicating there is no search results found. We can set the desire text to be displayed for indicating no results found with the NoResultsFoundText and NoResultsFoundTemplate properties.
NoResultsFoundText
We can customize the desire text to be displayed for indicating no results found by using the NoResultsFoundText property.
<editors:SfComboBox x:Name="comboBox"
IsEditable="True"
IsFilteringEnabled="True"
NoResultsFoundText="Not Found"
ItemsSource="{Binding SocialMedias}"
TextMemberPath="Name"
DisplayMemberPath="Name" />SfComboBox comboBox = new SfComboBox()
{
IsFilteringEnabled = true,
IsEditable = true,
NoResultsFoundText = "Not Found",
ItemsSource = socialMediaViewModel.SocialMedias,
TextMemberPath = "Name",
DisplayMemberPath = "Name",
};
NoResultsFoundTemplate
We can customize the appearance of the desire text to be displayed for indicating no results found by using the NoResultsFoundTemplate property.
<editors:SfComboBox x:Name="comboBox"
ItemsSource="{Binding SocialMedias}"
IsEditable="True"
IsFilteringEnabled="True"
TextMemberPath="Name"
DisplayMemberPath="Name">
<editors:SfComboBox.NoResultsFoundTemplate>
<DataTemplate>
<Label Text="Not Found" FontSize="20" FontAttributes="Italic" TextColor="Red" Margin="70,10,0,0"/>
</DataTemplate>
</editors:SfComboBox.NoResultsFoundTemplate>
</editors:SfComboBox>SfComboBox comboBox = new SfComboBox()
{
ItemsSource = socialMediaViewModel.SocialMedias
TextMemberPath = "Name",
DisplayMemberPath = "Name",
NoResultsFoundTemplate = new DataTemplate(() =>
{
return new Label
{
Text = "Not Found",
FontSize = 20,
FontAttributes = FontAttributes.Italic,
TextColor = Colors.Red,
Margin = new Thickness(70, 10, 0, 0)
};
})
};
NOTE
By Default NoResultsFoundText is enabled we can restrict it by using NoResultsFoundTextas Empty.