Wednesday, July 2, 2014

AutoSuggestBox in Winows Phone 8.1

This is completely new controller for windows store app development that comes with Windows Phone 8.1 . But this still not available to Windows 8.1 or 8.1 Update 1.

Very cool feature feel like combo box and text box both are in together.


Here is the XAML code for controller.
<AutoSuggestBox x:Name="suggestions" HorizontalAlignment="Left" Margin="52,62,0,0" 
ItemsSource="{Binding }" VerticalAlignment="Top"
Width="296" TextChanged="suggestions_TextChanged"
SuggestionChosen="suggestions_SuggestionChosen"/>

You need to bind observationCollection with AutoSuggestBox .

You can define what will happen when text changed and item selected as this

 private void suggestions_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
{
Suggestions.Clear();
Suggestions.Add(sender.Text + "1");
Suggestions.Add(sender.Text + "2");
Suggestions.Add(sender.Text + "3");
Suggestions.Add(sender.Text + "4");
}
}

private void suggestions_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
suggestions.Text = "Choosen";
}


Here is screen Shot



























Full Code In Media Fire 
http://bit.ly/TOOVCO

 





0 comments: