簡體   English   中英

標簽頁和底部導航中的靜態標題?

[英]Static header in tabbed page and bottom navigation?

在使用基於選項卡式頁面的底部導航時,有沒有辦法創建固定在屏幕頂部的靜態標題? 導航時,頁面向左/向右滑動,當前標題跟隨它。 標頭由具有以下代碼的模板創建:

<ResourceDictionary>
        <ControlTemplate x:Key="Template">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.1*" />
                </Grid.RowDefinitions>
                <BoxView Color="Black" />
                <Label 
                    Text="xyz"
                    TextColor="White"
                    FontSize="15"
                    FontFamily="Helvetet"
                    VerticalOptions="Center"
                    HorizontalOptions="Start"/>
                <ContentPresenter Grid.Row="1" VerticalOptions="Center"/>
            </Grid>
        </ControlTemplate>
    </ResourceDictionary>

盡管頁面向左/向右滑動,但應該進行哪些更改,以便標題卡在頂部?

這是它當前外觀的示例在此處輸入圖片說明

您可以將MainPage設置為NavigationPage ,然后將其RootPage設置為TabbedPage 然后你會得到一個靜態的 Header 甚至切換選項卡項。

例如, App.Xaml.cs是:

public App()
{
    InitializeComponent();
   
    MainPage = new NavigationPage(new CustomTabbedPage());
}

CustomTabbedPageXaml是:

<?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="clr-namespace:AppForms19"
             xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
             android:TabbedPage.ToolbarPlacement="Bottom"
             Title="Main Title"
             x:Class="AppForms19.Views.CustomTabbedPage">
    <local:MainPage Title="One" IconImageSource="icon.png"/>
    <local:SecondPage Title="Two" IconImageSource="icon.png" />
</TabbedPage>

效果:

在此處輸入圖片說明

暫無
暫無

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

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