Introducing Binding
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 ...
Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.