Wpf custom control binding not updating

This behavior is controlled by a property on the binding called Update Source Trigger.It defaults to the value "Default", which basically means that the source is updated based on the property that you bind to.Ultimately, you can choose to both observe and update, so that changes that the user makes to values in the UI are automatically pushed back into the data source.

wpf custom control binding not updating-28wpf custom control binding not updating-47

The Update Source Trigger property of a binding controls how and when a changed value is sent back to the source.

However, since WPF is pretty good at controlling this for you, the default value should suffice for most cases, where you will get the best mix of a constantly updated UI and good performance.

As of writing, all properties except for the Text property, is updated as soon as the property changes (Property Changed), while the Text property is updated when focus on the destination element is lost (Lost Focus).

Default is, obviously, the default value of the Update Source Trigger.

The second Text Box uses the Lost Focus value, which is actually the default for a Text binding.

It means that the source value will be updated each time the destination control loses focus.

The third and last Text Box uses the Property Changed value, which means that the source value will be updated each time the bound property changes, which it does in this case as soon as the text changes.

Try running the example on your own machine and see how the three textboxes act completely different: The first value doesn't update before you click the button, the second value isn't updated until you leave the Text Box, while the third value updates automatically on each keystroke, text change etc.

If you want the full control, you can use the Explicit value and then do the updates manually, but this does take a bit of the fun out of working with data bindings.

I am Technology Director at Scott Logic and am a prolific technical author, blogger and speaker on a range of technologies.

You can choose to use either the markup extension or the markup extension.

Tags: , ,