Product Spotlight
(0 votes)

Tip: How to declare child elements inside your control in XAML?

0 comments   /   posted by Denislav Savkov on Sep 05, 2008

All child elements in fact are properties. To indicate which property accepts the child element as its value you must specify the ContentProperty attribute of the class.

C#
[ContentProperty("PropertyName")]
public class SomeClass
{
    ...
    public PropertyType PropertyName {get;set;}
    ...
}
 
XAML
<SomeClass x:Name="someClassInstance">
    Value
</SomeClass>

This way the last declaration corresponds to the following C# code

C#

someClassInstance.PropertyName = Value;
That's it!

 

 

Filed under: Controls and UI


Comments

Comments RSS RSS
No comments

Add Comment