问题描述
我遇到的问题是,当我在这些页面之间导航时,我的侧边菜单突然消失了。
我已经尝试了“任何事情”,我的意思是我已经尝试了所有我能做的事情,但结果还是一样。
This is the view before I navigate to SettingsPage
This is the view after I navigate to SettingsPage
如您所见,菜单消失了。
代码:
<?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:MyTestApplication.Views"
xmlns:viewmodels="clr-namespace:MyTestApplication.viewmodels;assembly=MyTestApplication"
Title="MyTestApplication"
x:Class="MyTestApplication.AppShell">
<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}" />
<Style targettype="local:SettingsPage" BasedOn="{StaticResource BaseStyle}" />
<Style Class="MenuItemLayoutStyle" targettype="Layout" ApplyToDerivedTypes="True">
<Setter Property="visualstatemanager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="normal">
<VisualState.Setters>
<Setter TargetName="FlyoutItemLabel" Property="Label.TextColor" Value="{StaticResource Primary}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutContentTemplate>
<DataTemplate>
<StackLayout>
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding FlyoutItems}" ItemTapped="Settings_Button">
<ListView.Header>
<Grid BackgroundColor="Rosybrown">
<Grid.ColumnDeFinitions>
<ColumnDeFinition Width="10"/>
<ColumnDeFinition Width="*"/>
<ColumnDeFinition Width="10"/>
</Grid.ColumnDeFinitions>
<Grid.RowDeFinitions>
<RowDeFinition Height="30"/>
<RowDeFinition Height="80"/>
<RowDeFinition Height="Auto"/>
<RowDeFinition Height="10"/>
</Grid.RowDeFinitions>
<Label Grid.Row="2" Grid.Column="1"
TextColor="#d7d9b4"
Text="{Binding Title}"
FontSize="24"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="15,10"
HorizontalOptions="FillAndExpand">
<Label VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
Text="{Binding Type}"
TextColor="Black"
FontSize="20"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="MenuItemsListView2"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding FlyoutItems2}" ItemTapped="Home_Button">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="15,10"
HorizontalOptions="FillAndExpand">
<Label VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
Text="{Binding Type}"
TextColor="Black"
FontSize="20"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</DataTemplate>
</Shell.FlyoutContentTemplate>
<FlyoutItem Title="Home" Icon="home.png">
<ShellContent Route="MainPage" ContentTemplate="{DataTemplate local:MainPage}"/>
</FlyoutItem>
<FlyoutItem Title="Settings" Icon="setting.png">
<ShellContent Route="SettingsPage" ContentTemplate="{DataTemplate local:SettingsPage}" />
</FlyoutItem>
<TabBar >
<ShellContent Route="LoginPage" ContentTemplate="{DataTemplate local:LoginPage}" />
</TabBar>
</Shell>
欢迎提出任何想法!
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)