O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Binding and the AutoCompleteBox.Text Property

Populating the Text property of the AutoCompleteBox via a data binding can be problematic, since when a suggestion is chosen the binding is effectively removed and therefore needs to be restored.

You can reapply a binding by subscribing to the SelectionChanged event of the AutoCompleteBox.

void AutoCompleteBox_SelectionChanged(             object sender, SelectionChangedEventArgs e){    AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;    Dispatcher.BeginInvoke(delegate    {        Binding binding = new Binding("YourViewModelTextProperty");        binding.Source = autoCompleteBox.DataContext;        autoCompleteBox.SetBinding(AutoCompleteBox.TextProperty, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required