簡體   English   中英

Xamarin 表單選項卡式頁面

[英]Xamarin Form Tabbed page

嗨,我嘗試使用 Xamarin 開發我的第一個交叉應用程序,我嘗試做一個選項卡式頁面。 我的 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>

我的第 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>

我發現了更多使用我的方法的示例,但是當我構建解決方案時,我的錯誤是:

找不到類型“TabbedPage”。 找不到類型“local:page1”。

怎么了? 謝謝你的問候

所需的屏幕截圖: 在此處輸入圖片說明

新錯誤 - 新截圖:

我使用 ReSharper,它顯示了兩個問題:

  1. 此代碼錯誤xmlns:local="using:MyTimesheet.Pages" ,您必須將其更改為xmlns:local="clr-namespace:MyTimesheet.Pages,assembly=MyTimesheet"
  2. 檢查后面的 TabbedPage 代碼(TabbedPage.xaml.cs),對我來說,Visual Studio 創建了以下錯誤代碼public partial class TabbedPage : TabbedPage ,刪除繼承(使用public partial class TabbedPage ),對我來說,它有效。

我希望這可以幫助你。

更改您的xmlns:local="using:MyTimesheet.Pages並替換xmlns:views="clr-namespace:MyTimesheet.Views

然后將您的<local:Page1></local:Page1>替換為<view:Page1/> 這適用於我的項目。

添加

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

Xamarin 將自動添加您的引用

您也可以在頁面內設置標題

 <ContentPage  Title="page 4">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM