2017-02-21 20 views
0

我有我的份額「什麼f%$ @」Xamarin形式錯誤。但是,這一個頂部蛋糕。我花了大約3個小時的時間試圖弄清楚爲什麼這個頁面只設置爲504高度,而我沒有做任何事情似乎可以解決這個問題。從字面上看有一個空白頁面,如下所示:ContentPage的高度設置爲504?

<?xml version="1.0" encoding="utf-8" ?> 
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:controls="clr-namespace:XamarinMobile.Controls;assembly=XamarinMobile" 
      xmlns:local="clr-namespace:XamarinMobile.Classes;assembly=XamarinMobile" 
      xmlns:converters="clr-namespace:XamarinMobile.Converters;assembly=XamarinMobile" 
      xmlns:viewModels="clr-namespace:XamarinMobile.ViewModels;assembly=XamarinMobile" 
      xmlns:customRenderers="clr-namespace:XamarinMobile.CustomRenderers;assembly=XamarinMobile" 
      x:Class="XamarinMobile.CommentsPage"> 

     <Label Text="Test"></Label> 

    </ContentPage> 

我得到這樣的結果:

enter image description here

從字面上看它等同於沒有此問題的其他頁面。任何見解?任何方式強制它是屏幕高度的最低高度?很煩人。

+0

你檢查designer.cs文件? – MiltoxBeyond

+0

我檢查過它嗎? – jdmdevdotnet

+0

任何可能在生成的代碼隱藏中專門設置值的東西。基本上搜索'.Height =' – MiltoxBeyond

回答

0

所以這個問題似乎是我沒有調用我需要調用的方法。

NavigationPage.SetHasNavigationBar

https://developer.xamarin.com/api/member/Xamarin.Forms.NavigationPage.SetHasNavigationBar/p/Xamarin.Forms.BindableObject/System.Boolean/

的這個行爲是奇數。如果你沒有指定它,它會爲導航欄「分配」空間。你會認爲它默認爲false,但似乎它默認爲true。將它設置爲false固定的問題:

Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);

0

您可以手動設置佈局的高度以匹配屏幕。

App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width; 
App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height; 

然後設置一個relative或stacklayout爲height/width結果。我認爲你最好看看https://developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/並使用可能的垂直選項設置來填充stacklout佈局。我希望能夠匹配屏幕高度。

+0

不,'App.ScreenHeight'設置正確。事實上,我已經做了你的代碼。我將'HeightRequest'和'MinimumHeightRequest'設置爲'App.ScreenHeight'(我調試時爲568),然後以某種方式將它設置爲504。 – jdmdevdotnet