Xamarin.Forms.ContentPage Class
A Xamarin.Forms.Page that displays a single view.

See Also: ContentPage Members

Syntax

[Xamarin.Forms.ContentProperty("Content")]
public class ContentPage : Page

Remarks

This is a Page displaying a single View, often a container like a Xamarin.Forms.StackLayout or Xamarin.Forms.ScrollView.

The example below is taken from he App.cs file that is contained in the default "Hello, Forms!" app. It uses a Xamarin.Forms.ContenPage to display a label, which is a typical, though basic, use of the Xamarin.Forms.ContenPage class.

C# Example

using System;
using Xamarin.Forms;

namespace ContentPageExample
{
    public class App
    {
        public static Page GetMainPage ()
        {    
            return new ContentPage { 
                Content = new Label {
                    Text = "Hello, Forms!",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                },
            };
        }
    }
}
          

The FormsGallery sample, which can be found on the Sample Applications page, has a ContentPageDemoPage.cs file. This file contains a longer and more complicated example.

The Xamarin.Forms.ContentPage class has the following XAML property:

PropertyValue
Content

A list of Xamarin.Forms.View objects that represent the visual content of the Xamarin.Forms.ContentPage. This tag can be omitted, and the contents listed directly.

A ContentPage tag can be the root element of a XAML document.

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