Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page Title doesn't display in Xamarin.Forms project

I am working on Xamarin.Forms.

When I created blank Xamarin.Forms project there are four project created in one solution, one for iOS, one for Android, one for Windows and one is the Portable project (Common Project).

I add one XAML form named "Page2.XAML" with this code:

<?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="Rutul_App.Page2"
             Title="aaaa">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="ABC" HorizontalOptions="Center"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

and in the code behind file:

namespace Rutul_App
{
    public partial class Page2 : ContentPage
    {
        public Page2()
        {
            InitializeComponent();
        }
    }
}

In App.cs page I have added:

public App()
    {
        // The root page of your application
        MainPage = new NavigationPage(new Page2());
    }

Problem :

My problem is that the title and the BackGroundImage don't display. There are so many property that doesn't work.

My page is inherit form ContentPage but I can't access property of the ContentPage class. Properties are public.

Why is my title not being displayed?

like image 992
RMR Avatar asked Jul 12 '16 09:07

RMR


2 Answers

You can define the page as NavigationPage in App.xaml.cs, without declaring NavigationPage in the xaml file, i.e. like so in App.xaml.cs:

InitializeComponent();

MainPage = new NavigationPage(new Page2());
like image 191
fugu2 Avatar answered Oct 23 '22 04:10

fugu2


Try

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Rutul_App.Page2"
             Title="aaaa" NavigationPage.HasNavigationBar="True">
like image 38
Manu Mohan Thekkedath Avatar answered Oct 23 '22 05:10

Manu Mohan Thekkedath