How to Set the Minimum Characters for AutoCompleteBox to filter in Windows Phone ?

The AutoCompleteBox that is part of Silverlight Toolkit for Windows Phone by default shows the suggestions when you type one character in the AutoCompleteBox .

You can change this behaviour . For example , if you want to display the Suggestions in the Autocompletebox if you type 3 characters or more , you can set the property MinimumPrefixLength to 3 .

How to Set the Minimum Characters for AutoCompleteBox to filter in Windows Phone ?

Assume that the AutocompleteBox has the following List as ItemSource .

public List<string> GetSports()

{

List<string> Sports = new List<string>();

Sports.Add("Cricket - One Day");

Sports.Add("Cricket - Test");

Sports.Add("Tennis");

Sports.Add("Table Tennis");

Sports.Add("Hockey");

Sports.Add("Football");

return Sports;

}

If you Set the MinimumPrefixLength of the AutoCompleteBox to 3 , then you should get the the suggestion only when you type 3 or more characters as shown below

AutoCompleteBox txtbox = new AutoCompleteBox();

txtbox.MinimumPrefixLength = 3;

stack.Children.Add(txtbox);

// Data

txtbox.ItemsSource = GetSports();

If you dont want the AutocompleteBox to show the suggested words , then set the MinimumPrefixLength of AutoCompleteBox to -1 .

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...