使用AppShell时Xamarin Forms ContentPage底部未显示为白色是什么原因?
问题描述
我正在使用AppShell进行开发,当前遇到了ContentPage底部区域显示异常的问题:预期底部应为白色,但实际并未呈现该效果,详见下图:
我在代码中已添加如下配置:
BackgroundColor="White" Shell.BackgroundColor="White"
请问是什么原因导致该问题?
相关代码
BaseStyle样式代码
<Style x:Key="BaseStyle" TargetType="Element"> <Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark={StaticResource Primary}, Light={StaticResource Primary}}" /> <Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=Black, Light=White}" /> <Setter Property="Shell.TitleColor" Value="{AppThemeBinding Dark=Black, Light=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>
对应XAML页面代码
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="Toretto.MobileApp.Views.ForgetPasswordPage" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:behaviors1="clr-namespace:Toretto.MobileApp.Behaviors" xmlns:controls="clr-namespace:Toretto.MobileApp.Controls" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:local="clr-namespace:Toretto.MobileApp;assembly=Toretto.MobileApp" xmlns:r="clr-namespace:Toretto.MobileApp.LocalizationResources" BackgroundColor="White" Shell.BackgroundColor="White" Shell.NavBarIsVisible="False"> <ContentPage.Resources> <ResourceDictionary /> </ContentPage.Resources> <ContentPage.Content> <StackLayout VerticalOptions="StartAndExpand"> <StackLayout.Padding> <OnPlatform x:TypeArguments="Thickness"> <OnPlatform.Platforms> <On Platform="iOS" Value="0, 30, 0, 0" /> <On Platform="Android" Value="0, 0, 0, 0" /> </OnPlatform.Platforms> </OnPlatform> </StackLayout.Padding> <StackLayout BackgroundColor="{StaticResource Primary}" HeightRequest="60" Orientation="Horizontal"> <Image x:Name="BackImage" Margin="10,0,0,0" HeightRequest="36" Source="{local:ImageResource Toretto.MobileApp.Resources.Images.back.png}" VerticalOptions="CenterAndExpand" WidthRequest="36"> <Image.GestureRecognizers> <TapGestureRecognizer Command="{Binding BackCommand}" /> </Image.GestureRecognizers> </Image> <Label Margin="-40,10,0,0" FontSize="Medium" HorizontalOptions="CenterAndExpand" Text="{x:Static r:Resource.ForgetPasswordTitle}" TextColor="White" VerticalOptions="CenterAndExpand" /> </StackLayout> <Label Margin="20,20,20,0" FontSize="Medium" HorizontalOptions="StartAndExpand" Text="{x:Static r:Resource.ForgetPasswordSubtitle}" TextColor="{StaticResource TorettoDarkColor}" /> <Label x:Name="EmailErrorLabel" FontSize="Small" HorizontalOptions="CenterAndExpand" IsVisible="True" Style="{StaticResource ValidationErrorLabelStyle}" Text="{Binding Email.Errors, Converter={StaticResource ValidationErrorConverter}}" /> <Label Margin="20,10,20,0" FontFamily="Lobster-Regular" FontSize="Medium" Text="{x:Static r:Resource.User}" TextColor="{StaticResource TorettoDarkColor}" /> <controls:CustomEntry x:Name="customEntryEmail" Margin="20,0,20,10" IsPassword="False" Style="{StaticResource CustomEntryStyle}" Text="{Binding Email.Value, Mode=TwoWay}"> <Entry.Behaviors> <behaviors1:EventToCommandBehavior Command="{Binding ValidateEmailCommand}" EventName="TextChanged" /> </Entry.Behaviors> <!-- 示例 --> <Entry.Triggers> <Trigger TargetType="Entry" Property="IsFocused" Value="True"> <Setter Property="BackgroundColor" Value="{StaticResource TorettoLightColor}" /> <!-- 可添加多个Setter节点 --> </Trigger> </Entry.Triggers> </controls:CustomEntry> <Button x:Name="loginButton" Margin="20,20,20,20" Command="{Binding SendCommand}" HeightRequest="40" Text="{x:Static r:Resource.Send}" TextColor="White" VerticalOptions="Center"> <Button.Triggers> <DataTrigger Binding="{Binding Source={x:Reference customEntryEmail}, Path=Text.Length}" TargetType="Button" Value="0"> <Setter Property="IsEnabled" Value="False" /> </DataTrigger> </Button.Triggers> </Button> </StackLayout> </ContentPage.Content> </ContentPage>
内容的提问来源于stack exchange,提问作者saramgsilva
相关产品推荐
相关产品推荐

