You can either use Events in XAML to change properties or you can bind one object to another directly in the markup.
Let’s say you wanted to change the text of a button to match the text property of a textbox, when it changes.
All you need to do, is for the Content property of the button (like the ‘Text’ property in .Net), you would use Property Binding with the following syntax:
<Button Content="{Binding ElementName=YourTextBoxName, Path=Text}"
Remember to use the curly brackets around the Content value. In this case, since we’re changing the Text of the Textbox to affect the Button’s ‘Content’ (what appears in the Button), you use
Path=Text
And that’s all there is to it to be able to affect one object from another using Property Binding.
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF
Leave a reply
You must be logged in to post a comment.