【问题标题】:Adding my own pages to bottom navigation将我自己的页面添加到底部导航
【发布时间】:2018-12-18 00:17:49
【问题描述】:

我正在关注本指南 (https://15mgm15.ghost.io/2018/06/06/bottom-tabbed-page-for-xamarin-forms-android/),但我不知道如何将我添加到项目中的页面添加到项目中。

我需要在此处添加一些内容,以便应用了解要显示哪些页面:

<TabbedPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:bottom"
    x:Class="bottom.MainPage">
    <TabbedPage.Children>
        <ContentPage Title="Page 1" Icon="death_star.png"/>
        <ContentPage Title="Page 2" Icon="green_star.png"/>
        <ContentPage Title="Page 3" Icon="star.png"/>
    </TabbedPage.Children>
</TabbedPage>

现在,它只显示标签页,因为它不知道从哪些页面获取信息。

【问题讨论】:

    标签: xamarin xamarin.forms tabs bottomnavigationview tabbedpage


    【解决方案1】:

    强烈建议您阅读官方文档:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/tabbed-page

    如果您尝试将现有 XAML 页面添加到选项卡式页面,则需要将上面代码中的每个 ContentPage 元素替换为您想要的页面。

    例如,如果您有一个名为“MyTestPage”的页面

    <TabbedPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:bottom"
    x:Class="bottom.MainPage">
    <TabbedPage.Children>
        <MyTestPage Title="Page 1" Icon="death_star.png"/>
        <ContentPage Title="Page 2" Icon="green_star.png"/>
        <ContentPage Title="Page 3" Icon="star.png"/>
    </TabbedPage.Children>
    

    【讨论】:

    • 感谢您的帮助,但出现此错误:“对象引用未设置为对象的实例。”。 @App 包
    • 你需要使用&lt;local:MyTestPage /&gt;而不是&lt;MyTestPage/&gt;
    • @KalleP 请在此页面的 xaml.cs 文件中为 intializeComponent() 编写 try-catch 并将调试点放在 catch 上,然后查看异常,它将有更多详细信息。如果您提供细节我可以进一步帮助你。
    • 我希望你已经解决了你的问题@KalleP,如果是,那么你应该提供解决方案作为答案。
    猜你喜欢
    • 2020-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-03
    • 2015-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多