TAGS :Viewed: 9 - Published at: a few seconds ago

[ What is Content Properties in XAML? ]

The microsoft has define the meaning of content properties as "XAML specifies a language feature whereby a class can designate exactly one of its properties to be the XAML content property. Child elements of that object element are used to set the value of that content property. In other words, for the content property uniquely, you can omit a property element when setting that property in XAML markup and produce a more visible parent/child metaphor in the markup."

This is very confuse to me. Can anyone explain me by giving some simple example.

Answer 1

Consider a XAML control such as a Button. You can define it as follows, setting its Content property thus:

<Button Content="Click Me" />

Alternatively, you can define the Content property using the child elements of the Button. Here, the TextBlock becomes the value of the Button's Content property:

    <TextBlock Text="Click Me" />