Skip Navigation LinksHome / Tips / View Tip

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

+ Add to SilverlightShow Favorites
1 comments   /   posted by Denislav Savkov on Sep 05, 2008
(0 votes)
Categories: Controls and UI

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.

public class SomeClass
    public PropertyType PropertyName {get;set;}
<SomeClass x:Name="someClassInstance">

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


someClassInstance.PropertyName = Value;
That's it!





Comments RSS RSS
  • RE: Tip: How to declare child elements inside your control in XAML?  

    posted by Dave on Jan 05, 2009 19:34

    This doesn't seem work with UserControls. Complains that "'System.Windows.Controls.UserControl.ContentProperty' is a 'field' but is used like a 'type'"

Add Comment


Please add 8 and 6 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)