![](/img/trans.png)
[英]Use PreferenceFragment in Bottom Navigation Tabbed Application
[英]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());
}
而CustomTabbedPage的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="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.