Validating a TextBox as the User Types
UpdateSource method forces the target property value to be assigned to its source property. This allows you to perform input validation while the user is entering text into a
TextBox, rather than after the
TextBox loses focus.
I have created a class called
UpdateSourceTriggerExtender, which contains an attached property that is used to trigger an update of the binding source whenever the
TextBox’s text changes.
When the attached property is placed on a
HandleUpdatePropertyChanged method is called, which subscribes to the
TextBox.TextChanged event (see Listing 26.1). When the text is changed the
BindingExpression for the