O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding to Plain Properties

Although the target property must be a dependency property, the source property can be any (public) property. This can be demonstrated with a slight twist to the previous example. In this case, the TextBlock next to the TextBox displays the number of characters in its text by binding to the simple Length property on the string Text property:

<StackPanel Orientation="Horizontal">  <!-- The user can type anything here -->  <TextBox Name="textBox"/>  <!-- This displays the # of characters -->  <TextBlock>    <Run>Characters used: </Run>    <Run Text="{Binding ElementName=textBox, Path=Text.Length}"/>  </TextBlock></StackPanel>

In this case, the character count automatically stays up-to-date, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required