Class ContentPropertyAttribute
- Namespace
- Icy.Markup
- Assembly
- IcyUI.dll
Designates the property that a type's markup child elements and bare text are written into, letting markup omit the property name entirely.
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public sealed class ContentPropertyAttribute : Attribute
- Inheritance
-
ContentPropertyAttribute
- Inherited Members
- Extension Methods
Remarks
With [ContentProperty(nameof(Panel.Children))] on Panel, this markup:
<StackPanel>
<TextBlock>Hello</TextBlock>
</StackPanel>
adds the TextBlock to Children without naming it. The content property's
kind decides what happens: an IList has children added to it, and
anything else is assigned a single child - a second child is then an error.
The attribute is inherited, so a type only declares its own when it differs from its base's.
Constructors
ContentPropertyAttribute(string)
Designates the property that a type's markup child elements and bare text are written into, letting markup omit the property name entirely.
public ContentPropertyAttribute(string name)
Parameters
namestringThe name of the property markup content is written into.
Remarks
With [ContentProperty(nameof(Panel.Children))] on Panel, this markup:
<StackPanel>
<TextBlock>Hello</TextBlock>
</StackPanel>
adds the TextBlock to Children without naming it. The content property's
kind decides what happens: an IList has children added to it, and
anything else is assigned a single child - a second child is then an error.
The attribute is inherited, so a type only declares its own when it differs from its base's.
Properties
Name
Gets the name of the property markup content is written into.
public string Name { get; }
Property Value
Methods
GetContentPropertyName(Type)
Gets the name of the content property declared by type or inherited from one of its
base types.
public static string? GetContentPropertyName(Type type)
Parameters
typeTypeThe type to look the content property up for.