问题描述
我正在开发 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 (将#修改为@)