Xamarin.Forms Guides | Samples

Xamarin.Forms.ContentPropertyAttribute Class

Indicates the property of the type that is the (default) content property.

See Also: ContentPropertyAttribute

Syntax

[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class ContentPropertyAttribute : Attribute

Remarks

XAML processor uses to determine the content property.

Decorating types with ContentPropertyAttribute allows shorter XAML syntax. As

ContentView has a ContentProperty attribute applied, this XAML is valid:

C# Example

<ContentView>
  <Label Text="Hello, Forms"\>
</ContentView>
This is equivalent to the following, more explicit XAML

C# Example

<ContentView>
  <ContentView.Content>
    <Label Text="Hello, Forms"\>
  </ContentView.Content>
</ContentView>

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

The members of Xamarin.Forms.ContentPropertyAttribute are listed below.

See Also: Attribute

Public Constructors

Initializes a new instance of the ContentPropertyAttribute class.

Public Properties

[read-only]
NameString. Gets the name of the content property