Xamarin.Forms Guides | Samples

Xamarin.Forms.ContentView Class

An element that contains a single child element.

See Also: ContentView

Syntax

[Xamarin.Forms.ContentProperty("Content")]
public class ContentView : TemplatedView

Remarks

XAML for Xamarin.Forms supports the following property for the ContentView class:

PropertyValue
Content

The View object that represents the visual content of the ContentView.

The following example shows how to construct a new ContentView with a Label inside.

C# Example

MainPage = new ContentPage () {
    // Accomodate iPhone status bar.
    Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5),
        Content = new ContentView {
            Content = new Label { Text = "I'm Content!" },
    }
};

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.ContentView are listed below.

See Also: TemplatedView

Public Constructors

Initializes a new instance fo the ContentView class.

Public Fields

static readonly
ContentPropertyBindableProperty. Backing store for the ContentView.Content property..

Public Properties

ContentView. Gets or sets the content of the ContentView.

Protected Methods

override
LayoutChildren(Double, Double, Double, Double)
Positions and sizes the content of a ContentView.
override
OnBindingContextChanged()
Method that is called when the binding context changes.
override
OnSizeRequest(Double, Double) : SizeRequest
This method is called during the measure pass of a layout cycle to get the desired size of the ContentView.