Thursday, June 21, 2007

How to specify which property of my custom class should take the Content from xaml?

Use System.Windows.Markup.ContentProperty attribut on the class
Eg:
If you are creating a custom class for clock control and wanna Time to take the Content from xaml use as follows.

[System.Windows.Markup.ContentProperty("Time")]
public class Clock : Control {
public DateTime Time{
}
}

Hence the xaml looks like

<MyControl:Clock >
4:30:34
</MyControl:Clock >

No comments:

Post a Comment