Wpf textblock text binding not updating

02-Aug-2019 01:06

As you can see, each of the three textboxes now uses a different Update Source Trigger.

The first one is set to Explicit, which basically means that the source won't be updated unless you manually do it.

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 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.

And the problem in reality is in all your Text Box’s’ binding: Your bindings are so simple format, only binding to the property (in the above case ‘Path’), The binding in the above case has all other properties set to default values except the one set explicitly ‘Path’. Update Source Trigger It’s set to Default by default.

Which means the Text Box Binding source wont be updated unless the Text Box losses input focus.

In the Code-behind, you will find the Click handler, where we use a couple of lines of code to get the binding from the destination control and then call the Update Source() method on it.

The song name and band name can be two different fields in your class.

(BTW if you remember this song, then you are Awesome AND Old. You can use this technique to bind two or more values to the same Text Block.

In the previous article we saw how changes in a Text Box was not immediately sent back to the source.

Instead, the source was updated only after focus was lost on the Text Box.

In the Code-behind, you will find the Click handler, where we use a couple of lines of code to get the binding from the destination control and then call the Update Source() method on it.

The song name and band name can be two different fields in your class.

(BTW if you remember this song, then you are Awesome AND Old. You can use this technique to bind two or more values to the same Text Block.

In the previous article we saw how changes in a Text Box was not immediately sent back to the source.

Instead, the source was updated only after focus was lost on the Text Box.

You can refer to the samples cited in this topic for more information.