简体   繁体   中英

Xamarin Form Tabbed page

Hi I try to develop my first cross app with Xamarin, I try to do a tabbed page. my xaml code is

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="using:MyTimesheet.Pages"

             x:Class="MyTimesheet.MainRootPage">
    <!--Pages can be added as references or inline-->

    <local:Page1></local:Page1>
    <local:Page2></local:Page2>
</TabbedPage>

My page1 and page 2 the xaml code are the same:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyTimesheet.Pages.ClientiPage">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome Clienti" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

I found more example that use my approch but when i build a solution my error are:

the type 'TabbedPage' could not found. the type 'local:page1' could not found.

what is wrong? thankyou regards

the screenshot required: 在此处输入图片说明

New error - new screenshot:

I use ReSharper and it shows me two problems:

  1. This code is wrong xmlns:local="using:MyTimesheet.Pages" , you have to changed it to xmlns:local="clr-namespace:MyTimesheet.Pages,assembly=MyTimesheet"
  2. Check the TabbedPage code behind (TabbedPage.xaml.cs) and for me Visual Studio creates the following wrong code public partial class TabbedPage : TabbedPage , remove the inherit (use public partial class TabbedPage ) and for me, it works.

I hope this can help you.

Change your xmlns:local="using:MyTimesheet.Pages and replace xmlns:views="clr-namespace:MyTimesheet.Views

Then replace your <local:Page1></local:Page1> with <view:Page1/> . That works in my projects.

add

<Page1   Title="Page 1" /> 
<Page2   Title="Page 2" /> 

Xamarin will Automatically Add your References

also you can set title inside pages

 <ContentPage  Title="page 4">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM