I have a Windows phone app with a TextBox two-way bound to a string property in my ViewModel, and on the same page a Button bound to an MVVM Light RelayCommand property in the ViewModel. The relay command's CanExecute method checks to see if the TextBox is empty and if it is, returns FALSE. Otherwise it returns TRUE so the user only presses the button after they have entered some text.
The problem is that I needed it to generate property changed notifications on every keystroke, not just when the TextBox lost focus. I did some reading and the way to do that is to set the UpdateSourceTrigger on the TextBox to PropertyChanged. However, in Windows Phone 8 it appears that enum value is not supported, only Default and Explicit. I double-checked this both in the XAML editor and in the Create Data Binding editor. Because of this I was forced to use the Explicit option and now have to call the following code in the TextBox TextChanged event handler as per the MSDN docs:
private void txtInput_TextChanged(object sender, TextChangedEventArgs e)
{
BindingExpression be = txtInput.GetBindingExpression(TextBox.TextProperty);
be.UpdateSource();
}
Where did the Propertychanged option go in Windows Phone 8? Am I just doing something wrong? Obviously I'd like to avoid doing this extra plumbing every time I want this behavior with a TextBox. I'm fine with writing a derived TextBox control to get this behavior but if I don't have to I'd like to know of course.