Content Page in Xamarin Forms XAML

The simplest of the Xamarin Page controls is the ContentPage. There is a template for this in Xamarin Studio so you can use the Add > New File... option. Here is the XAML so you can see a ContentPage along with a placeholder BoxView control so there is some content to see.

<!--?xml version="1.0" encoding="UTF-8"?-->
<ContentPage
	xmlns="http://xamarin.com/schemas/2014/forms"
	xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
	x:class="NogginXamarinFormSample.MyPage"
	Title="A Content Page">
		<BoxView Color="Silver" />
</ContentPage>

To show this page as the first page in your app you need the following in your App class.

public class App
{
	public static Page GetMainPage()
	{
		return new MyPage();
	}
}

This code is all in your portable class library project and the various platform specific initialisations will new it up.

Other Page Controls

No Comments