Category / Section
How to change suggestion mode based on search criteria?
1 min read
To change the Suggestion mode based on search criteria, follow the given steps:
Step 1: Create the AutoComplete sample and include the necessary source files.
Step 2: Create an instance for AutoComplete.
Step 3: Create an instance for List and populate it using Add() function.
Step 4: Then assign the populated list to AutoComplete’s AutoCompleSource property.
Step 5: By using the object you can change the suggestion display as follows:
C#
public partial class AutoCompletePage : ContentPage { SfAutoComplete autoComplete; public AutoCompletePage() { InitializeComponent(); autoComplete = new SfAutoComplete(); autoComplete .SuggestionMode = SuggestionMode.Contains; List<string> list = new List<string>(); list .Add("Afghanistan"); list .Add("Akrotiri"); list .Add("Albania"); list .Add("Algeria"); autoComplete.AutoCompleteSource = list; StackLayout stack = new StackLayout(); stack.Children.Add(autoComplete); this.Content = stack; } }
The following screenshot is an example to change the suggestion display mode:
StartsWith
StartsWithCaseSensitive
Contains
ContainsWithCaseSensitive
Equals
EqualsWithCaseSensitive
EndsWith
EndsWithCaseSensitive