DotNetRussell
DotNetRussell

Reputation: 9867

How does wpf know to set the Content property

So if I create a button in XAML,

<Button />

I can set the content one of a few ways

<Button Content="My Content" />

<Button>
    My Content
</Button>

<Button>
   <Button.Content>
         My Content
   </Button.Content>
</Button>

and etc...

My question is, when a user passes content in this way

<Button>
    My Content
</Button>

how does wpf know to assign the Content dependency property? This is pretty neat functionality I'd like to build into my controls.

Upvotes: 1

Views: 838

Answers (1)

SLaks
SLaks

Reputation: 887897

This comes from the [ContentProperty("Content")] attribute, which is set by ContentControl.

Upvotes: 4

Related Questions