![](/img/trans.png)
[英]Xamarin Forms with tabbed pages having data form entry page in each tabbed page
[英]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,它顯示了兩個問題:
xmlns:local="using:MyTimesheet.Pages"
,您必須將其更改為xmlns:local="clr-namespace:MyTimesheet.Pages,assembly=MyTimesheet"
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.