No Result Found in WinUI AutoComplete (SfAutoComplete)

25 Jul 20233 minutes to read

When the entered item is not in the suggestion list, SfAutoComplete 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 NoResultsFoundContent and NoResultsFoundTemplate properties.

NoResultsFoundContent

We can customize the desire text to be displayed for indicating no results found by using the NoResultsFoundContent property. The below code shows how to include the NoResultsFoundContent in AutoComplete.

<editors:SfAutoComplete  Header="AutoComplete with No Result Found Text" 
                          PlaceholderText="Search a country" 
                          DisplayMemberPath="Country" 
                          TextMemberPath="Country"
                          Width="300"   
                          NoResultsFoundContent="Not Found"
                          ItemsSource="{Binding ContinentList }">
 </editors:SfAutoComplete>

WinUI AutoComplete control with NoResultsFoundContent

NoResultsFoundTemplate

We can customize the appearance of the desire text to be displayed for indicating no results found by using the NoResultsFoundTemplate property. The below code shows how to include the NoResultsFoundTemplate in AutoComplete.

<editors:SfAutoComplete  Header="AutoComplete with No Result Found Template"
                           PlaceholderText="Search a country" 
                           DisplayMemberPath="Country" 
                           TextMemberPath="Country"
                           Width="300"    
                           ItemsSource="{Binding ContinentList }">
            <editors:SfAutoComplete.NoResultsFoundTemplate>
                <DataTemplate>
                    <TextBlock Text="Not Found" 
                        Foreground="Red" 
                        FontStyle="Italic" 
                        FontSize="20"  />
                </DataTemplate>
            </editors:SfAutoComplete.NoResultsFoundTemplate>
 </editors:SfAutoComplete>

WinUI AutoComplete control with NoResultsFoundTemplate

NOTE

While setting NoResultsFoundContent and NoResultsFoundTemplate properties. High priority is given to NoResultsFoundTemplate.