Is there a way to get a TextBox in Windows Phone 7 to update the Binding as the user types each letter rather than after losing focus?
Like the following WPF TextBox would do:
<TextBox Text="{Binding Path=TextProperty, UpdateSourceTrigger=PropertyChanged}"/>
In TextChanged event call UpdateSource().
You can write your own TextBox Behavior to handle Update on TextChanged:
This is my sample to PasswordBox but you can simple change it to handle any property of the any object.
Ussage:
It's just one line of code!
You can create a generic TextChanged event (for example "ImmediateTextBox_TextChanged") in the code behind of your page, and than link it to any TextBox in the page.
Silverlight for WP7 does not support the syntax you've listed. Do the following instead:
In C#:
UpdateSourceTrigger=Explicit doesnt work for me, hence Im using custom class derivated from TextBox
I took Praetorian's answer and made an extension class that inherits
TextBox
so you don't have to muddle up your view's code behind with this behavior.C-Sharp:
VisualBasic:
Then call like this in XAML: