VisualStudioFeeds

All Visual Studio blogs in one place

AddThis Social Bookmark Button
A small quicky this time: Problem: TextBox, Text property bound to a string in my ViewModel I type text in the TextBox I click a “Save” button on my ApplicationBar The string in my ViewModel is not updated. It never gets updated. WTF??? It appears the TextBox only updates it’s value to a bound string when it loses focus. And a TextBox does not lose focus when you click an ApplicationBar Button. Meh. I have found a few solutions and workarounds, and in the end rolled my own:  a very small behavior that updates
the binding every time you type something in your textbox. That’s a bit wasteful, but it works for me. It builds on the SafeBehavior pattern I wrote about earlier, and it’s so small I post it in one go:using System.Windows.Controls; namespace Wp7nl.Behaviors { /// /// A behavior to for text box model update when text changes /// public class TextBoxChangeModelUpdateBehavior : SafeBehavior { protected override void OnSetup() { AssociatedObject.TextChanged += AssociatedObjectTextChanged; } protected override void OnCleanup() ...(Read whole news on source site)

Search

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Home : Blog List : .NET by Example : Behavior to force TextBox model update to prevent trouble with the ApplicationBar