O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

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

Defining the Default Content Property

The Content property is the default property of the ContentControl. The ContentPropertyAttribute specifies which property of a class can be interpreted as the main content property when the class is parsed by a XAML processor. This means that when, for example, a TextBlock is placed as a nested element of a Button, the TextBlock is rendered within the button itself:

<Button>    <TextBlock Text="Press me!" Foreground="Orange" /></Button>

To further illustrate, the built-in control template for the Button control includes a Border that contains a TemplateBinding to the Content property of the Button, as shown in the following excerpt:

<Border>     ...

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