【问题标题】:Add Title For xamarin.forms Master Page Contain TabbedPage as Details page为 xamarin.forms 母版页添加标题包含 TabbedPage 作为详细信息页面
【发布时间】:2017-12-10 02:13:04
【问题描述】:

我使用主详细信息页面

详情页是一个标签页

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" ...... >
    <views:InboxPage    Title="" Icon="tabb_inbox.png" />
    <views:AgendaPage    Title="" Icon="tabb_agenda.png"/>
    <views:AttendancePage    Title="" Icon="tabb_attendance.png"/>
    <page:CalendarPage Title="" Icon="tabb_calendar.png" ></page:CalendarPage>
    <views:MarksPage    Title="" Icon="tabb_marks.png"/>
    <!--<views:CalendarPage Title="" Icon="tabb_calendar.png" />-->


</TabbedPage>

菜单(母版页)是一个内容页面:

     public partial class MasterPageMenu : ContentPage
        {
            public MasterPageMenu()
            {
                InitializeComponent();
                InitializeDataAsync();
}
}

在主页面渲染中使用以下

 public partial class MasterPage : MasterDetailPage
    {
  public MasterPage()
        {
Detail = new NavigationPage(bottomBarPage);

        Master = new MasterPageMenu()
        {
            Title = "The Title ",

            Icon = (Device.OS == TargetPlatform.iOS) ? "icon.png" : null
        };
}
}

有没有办法在菜单图标旁边显示页面标题

the result for above code like this

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:

    我通常在程序代码中传递标题如下(导航到页面时)。

    new tabbedPafe(){ Title = 'Put title here'};
    

    但我认为,如果您愿意的话,您也可以在您的 XAML 代码中执行此操作(在您的选项卡式页面中,为其提供 Title 属性)。

    <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" ...... Title="Title here">
    
    
     <views:InboxPage    Title="" Icon="tabb_inbox.png" />
        <views:AgendaPage    Title="" Icon="tabb_agenda.png"/>
        <views:AttendancePage    Title="" Icon="tabb_attendance.png"/>
        <page:CalendarPage Title="" Icon="tabb_calendar.png" ></page:CalendarPage>
        <views:MarksPage    Title="" Icon="tabb_marks.png"/>
        <!--<views:CalendarPage Title="" Icon="tabb_calendar.png" />-->
    
    </TabbedPage>
    

    【讨论】:

    • 谢谢,但是当我为标签页添加标题时,它不会显示在菜单图标旁边,它显示在图标下的标签页导航中
    • 啊,是的,我知道那个错误,我以前有过,我在我的旧项目中挖掘一下,看看能不能找到它
    • 哎呀,这是我的错,我希望导航页面的标题显示在菜单中,感谢您的评论通过添加标题解决了您提到的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-07
    • 2015-03-04
    • 2012-08-05
    • 2020-11-01
    • 2016-09-22
    • 1970-01-01
    相关资源
    最近更新 更多