Two-Way Binding and Deactivating Windows Phone Apps

14 December 2012

I'm not 100% sure on this, but for Windows Phone development it seems like if you have a textbox with two-way binding, it's not guaranteed to hit the setter for your property if you exit the app.

At least, this is what I figured after the n-th time debugging my app, which was working fine if you left the page normally, but was not persisting changes to database if the app was exited via the Start button. I added an additional explicit assignment of TextBox.Text to my Model prior to saving on the OnNavigatedFrom event, and everything worked fine after.

It's maybe another thing to try if anyone out there is using two way binding and wondering why it isn't quite working in edge cases like App Deactivation.

EDIT: Also, I wouldn't recommend making page event methods, like OnNavigatedFrom, into async methods. It just doesn't seem to play very well...

Tags: Windows Phone, XAML

Add a Comment

No Comments