gray laptop computer showing html codes in shallow focus photography

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

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...