WPF Reflections

Mar 4 2008   5:56PM GMT

Controlling how the source is updated in a binding



Posted by: MarkWPF
Tags:
WPF

Have you ever wondered how to alter the update frequency of a binding?
Probrably like me, you use the default settings unless you notice something not working
:-)

What am I talking about?
Well, when you have a binding defined to another element for example:

<TextBox Name=”txtFirstOne” />
<TextBox Text=”{Binding ElementName=txtFirstOne, Path=Length” Name=”txtFontSize” />

The second textbox will display the length of the text in the first textbox, as you type. Well actually it doesn’t, as the target is not being updated. To fix that you could add UpdateSourceTrigger=PropertyChanged for this example, and bingo:

<TextBox Text=”{Binding ElementName=txtFirstOne, Path=Length, UpdateSourceTrigger=PropertyChanged” Name=”txtFontSize” />

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: