如何解决设置默认页面并添加标签点击事件
我正在开发 Xamarin Forms 应用程序,我的问题包括两个因素:
- 我需要登录页面作为启动页面。如果我设置了
CurrentItem="{x:Reference hoMetab}
(或loginTab
),底部的TabBar
将不再出现在任何页面上。目前它仅在登录时隐藏,即使我在主页上设置Shell.TabBarIsVisible="True"
它也不会出现。此外,删除CurrentItem
行将使其再次可见。 - 如何在
TabBar
上设置点击事件?我需要在背后有一些逻辑,而不仅仅是导航到特定路线。
下面是我的 shell xaml:
<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:PlusErp.Wms.Mobile.Views"
xmlns:resources="clr-namespace:PlusErp.Wms.Mobile.Resources"
Title="PlusErp.Wms.Mobile"
x:Class="PlusErp.Wms.Mobile.AppShell"
CurrentItem="{x:Reference hoMetab}"
>
<!--
The overall app visual hierarchy is defined here,along with navigation.
https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
-->
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" targettype="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.disabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.TabBarForegroundColor" Value="White"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
<Setter Property="Shell.TabBarTitleColor" Value="White"/>
</Style>
<Style targettype="TabBar" BasedOn="{StaticResource BaseStyle}" />
<Style targettype="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
</ResourceDictionary>
</Shell.Resources>
<TabBar>
<ShellContent Title="{x:Static resources:AppResources.Back}" Icon="arrow_left.png" ContentTemplate="{DataTemplate local:HomePage}" />
<ShellContent x:Name="loginTab" Title="{x:Static resources:AppResources.logout}" Icon="logout.png" Route="LoginPage" ContentTemplate="{DataTemplate local:LoginPage}" />
<ShellContent x:Name="hoMetab" Title="{x:Static resources:AppResources.Home}" Icon="home.png" Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}" />
<ShellContent Title="{x:Static resources:AppResources.InfoStock}" Icon="search.png" ContentTemplate="{DataTemplate local:LoginPage}" />
<ShellContent Title="{x:Static resources:AppResources.Forward}" Icon="arrow_right.png" Route="ItemsPage" ContentTemplate="{DataTemplate local:ItemsPage}" />
</TabBar>
</Shell>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。