xamarin.forms winphone tabbedpage with multiple navigationpage Title

101 Views Asked by At

Hi I have just started using xamarin to try and develop a cross platform application but I have hit a problem very early on with my winphone project.

I have a tabbedpage which contains 2 navigationpages. Both these navigationpages have identical content the only thing that differs is the Title of each. The problem comes when swiping between the tabbed pages. When first loaded it renders correctly but once I have gone around the tabbed once I seem to lose a Title and the other 1 jumps to the top of the page which I don't want. The location tabbedpage renders fine.

When app is opened

After viewing the Location tab

MainPage.xaml

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:iLarm;assembly=iLarm"
         x:Class="iLarm.MainPage">
<NavigationPage Title="Alarm">
    <x:Arguments>
      <local:AlarmListPage />
    </x:Arguments>
  </NavigationPage>
  <NavigationPage Title="Location" >
    <x:Arguments>
      <local:LocationListPage />
    </x:Arguments>
  </NavigationPage>
</TabbedPage>

AlarmListPage.xaml

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="iLarm.AlarmListPage"
         Title="iLarm">
</ContentPage>

locationListPage.xaml

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="iLarm.LocationListPage"
         Title="iLarm">
</ContentPage>
1

There are 1 best solutions below

2
On

According to your codes, I wrote a demo. But the title of ContentPage didn't show at all.

From your screenshot I suppose you want to add title to top of the TabbedPage. According to this requirement you just need to set Title of TabbedPage likes below.

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:iLarm;assembly=iLarm"
         x:Class="iLarm.MainPage"
         Title="iLarm">
   <NavigationPage Title="Alarm">
       <x:Arguments>
           <local:AlarmListPage />
       </x:Arguments>
   </NavigationPage>

   <NavigationPage Title="Location">
       <x:Arguments>
           <local:LocationListPage />
       </x:Arguments>
   </NavigationPage>
</TabbedPage>