简体   繁体   English

Xamarin 表单选项卡式页面

[英]Xamarin Form Tabbed page

Hi I try to develop my first cross app with Xamarin, I try to do a tabbed page.嗨,我尝试使用 Xamarin 开发我的第一个交叉应用程序,我尝试做一个选项卡式页面。 my xaml code is我的 xaml 代码是

<?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:我的第 1 页和第 2 页的 xaml 代码相同:

<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.找不到类型“TabbedPage”。 the type 'local:page1' could not found.找不到类型“local:page1”。

what is wrong?怎么了? thankyou regards谢谢你的问候

the screenshot required:所需的屏幕截图: 在此处输入图片说明

New error - new screenshot:新错误 - 新截图:

I use ReSharper and it shows me two problems:我使用 ReSharper,它显示了两个问题:

  1. This code is wrong xmlns:local="using:MyTimesheet.Pages" , you have to changed it to xmlns:local="clr-namespace:MyTimesheet.Pages,assembly=MyTimesheet"此代码错误xmlns:local="using:MyTimesheet.Pages" ,您必须将其更改为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.检查后面的 TabbedPage 代码(TabbedPage.xaml.cs),对我来说,Visual Studio 创建了以下错误代码public partial class TabbedPage : TabbedPage ,删除继承(使用public partial class TabbedPage ),对我来说,它有效。

I hope this can help you.我希望这可以帮助你。

Change your xmlns:local="using:MyTimesheet.Pages and replace xmlns:views="clr-namespace:MyTimesheet.Views更改您的xmlns:local="using:MyTimesheet.Pages并替换xmlns:views="clr-namespace:MyTimesheet.Views

Then replace your <local:Page1></local:Page1> with <view:Page1/> .然后将您的<local:Page1></local:Page1>替换为<view:Page1/> That works in my projects.这适用于我的项目。

add添加

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

Xamarin will Automatically Add your References Xamarin 将自动添加您的引用

also you can set title inside pages您也可以在页面内设置标题

 <ContentPage  Title="page 4">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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