I have a simple page with just one TextBox control whose Text is bound to a property in my ViewModel. When I use UpdateSourceTrigger=Default, everything is fine, however, when I use UpdateSourceTrigger=PropertyChanged, I get an exception
{Failed to create a 'System.Windows.Data.UpdateSourceTrigger' from the text 'PropertyChanged'.}
When I click on the details of the exception, I get
{"You can only use State between OnNavigatedTo and OnNavigatedFrom"}
I am suspecting that this is because I set the DataContext for the binding in the NavigatedTo() function that is called AFTER the InitializeComponent() where the exception is thrown.
Any suggestions on how to get around this -- I really need the PropertyChanged trigger behavior.
Thanks.
Here are the 2 functions and XAML code for completeness:
public AddNewPlayerPage() { InitializeComponent(); } protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (_viewModel == null) { _viewModel = PhoneApplicationService.Current.State["ChooseItemVM"] as ChooseItemVM; DataContext = _viewModel; } }
<TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>