The key to data binding is a
Binding markup extension that “glues” two properties together and keeps a channel of communication open between them. You can set up a
Binding once and then have it do all the synchronization work for the remainder of the app’s lifetime.
Imagine that you have a
TextBlock with text that you want to automatically update as the user types in a
TextBox, such as the following:
<StackPanel Orientation="Horizontal"> <!-- The user should type a username here --> <TextBox Name="textBox" TextChanged="TextBox_TextChanged"/> <!-- This displays, "Hi, username!" --> <TextBlock> <Run>Hi, </Run> <Run x:Name="run"/> <Run>!</Run> </TextBlock></StackPanel>