奇怪的是,我的屏幕显示被按下只有主页,此后显示适合屏幕。我尝试删除该页面并重新添加,但这也没有用。有谁知道可能导致这种情况以及如何解决这个问题?
MainPage.xaml中
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="LoyaltyWorx.Views.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:LoyaltyWorx.Views.Converters"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
>
<ContentPage.Resources>
<ResourceDictionary>
<local:InvertBooleanConverter x:Key="InvertBooleanConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<Image Source="bk3.jpg" Aspect="AspectFill"/>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<!-- top controls -->
</StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<!-- middle controls -->
<BoxView HeightRequest="430"></BoxView>
<Button Text="Continue with Facebook" x:Name="LoginBtn" BackgroundColor="#4867aa" TextColor="White" FontFamily="Klavika" HorizontalOptions="CenterAndExpand" Clicked="LoginBtn_Clicked" />
<Button Text="Continue with Google " Command="{Binding GoogleLoginCommand}" BackgroundColor="#d34836" TextColor="White" FontFamily="Klavika" HorizontalOptions="CenterAndExpand"/>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End" HorizontalOptions="Center">
<!-- bottom controls -->
<Frame OutlineColor="White" HorizontalOptions="StartAndExpand">
<StackLayout Orientation="Horizontal" VerticalOptions="End" HorizontalOptions="Center">
<!-- bottom controls -->
<StackLayout Grid.Row="1" Orientation="Horizontal" Spacing="0">
<Label
Text="Terms and conditions"
FontSize="13"
TextColor="#71757a"
FontAttributes="Bold"
x:Name="LblTerms"/>
<Label
Text=" and"
FontSize="13"
TextColor="#71757a"
/>
<Label
Text=" privacy policy"
FontSize="13"
TextColor="#71757a"
FontAttributes="Bold"
x:Name="LblPrivacy"/>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</StackLayout>
</Grid>
</ContentPage>
App.cs
public partial class App : PrismApplication
{
public App(IPlatformInitializer initializer = null) : base(initializer) { }
protected override void OnInitialized()
{
InitializeComponent();
SetMainPage();
NavigationService.NavigateAsync("NavigationPage/MainPage?title=Hello%20from%20Xamarin.Forms");
}
protected override void RegisterTypes()
{
Container.RegisterTypeForNavigation<NavigationPage>();
Container.RegisterTypeForNavigation<MainPage>();
}
private void SetMainPage()
{
if (!string.IsNullOrEmpty(Helpers.Settings.Usertoken))
{
Application.Current.MainPage = (new Profile());
}
else
{
MainPage = new NavigationPage(new MainPage())
{ BarBackgroundColor = Color.FromHex("#393b3d") };
}
}
public async static Task NavigateToSMS()
{
await Application.Current.MainPage.Navigation.PushAsync(new SMS());
}
public static void NavigateToProfile()
{
Application.Current.MainPage = (new InvalidLogin());
}
public static void NavigateToVerified()
{
Application.Current.MainPage = (new Profile());
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
答案 0 :(得分:1)
您的MainPage
包含在NavigationPage
中,默认情况下会显示NavigationBar。您可以在cs代码或MainPage.xaml
CS
var mainPage = new MainPage();
MainPage = new NavigationPage(mainPage);
NavigationPage.SetHasNavigationBar(mainPage, false);
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="LoyaltyWorx.Views.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:LoyaltyWorx.Views.Converters"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
NavigationPage.HasNavigationBar="False">