Automatic text completion in AutoCompleteBox in Windows Phone

You can change this behaviour slightly such that the first possible suggested word / sentence is filled in the AutoCompleteBox .

To do that Just set the IsTextCompletionEnabled property of the AutoCompleteBox to True ..

public partial class MainPage : PhoneApplicationPage

{

// Constructor

public MainPage()

{

InitializeComponent();

AddAutocomplete();

}

public void AddAutocomplete()

{

AutoCompleteBox txtbox = new AutoCompleteBox();

txtbox.IsTextCompletionEnabled = true;

stack.Children.Add(txtbox);

// Data

txtbox.ItemsSource = GetSports();

}

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;

}

}

Leave a Reply