2
votes

I have a StackLayout in the MasterPage of a MasterDetailPage in Xamarin Forms, which has as VerticalOptions "FillAndExpand", but it doesn't fill the whole ContentPage in my UWP app (I don't know, if it works correctly on Android or iOS). In the screenshot you can see a green bar at the bottom left corner.

What can I do to make the StackLayout fill the whole MasterPage?

enter image description here

Here is my MasterPage:

<?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:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                 xmlns:local="clr-namespace:TobyList_XamarinForms"
                 Title="Toby" 
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="TobyList_XamarinForms.Views.MasterPage"
                 BackgroundColor="Green">

    <StackLayout Padding="5" VerticalOptions="FillAndExpand" BackgroundColor="#F9F9F9" />

</ContentPage>
2
also add HorizanalOptions=VerticalOptions="FillAndExpand"Mohamad Mahmoud
Adding "HorizontalOptions" makes no difference.mKay
put the backgroudcolor on the stacklayoutMohamad Mahmoud
The background color is just to demonstrate that the StackLayout is not filling the whole ContentPage. If I change the color, it's not visible anymore, but if I add something (like a button) to the bottom of the StackLayout, it is not at the bottom as it should be, because of this.mKay

2 Answers

2
votes

I wrapped the MasterPage in a NavigationPage and now the StackLayout fills the whole MasterPage as I wanted.

Now the app looks like this, without the green bar:

enter image description here

And here is the change in the XAML code of my MainPage:

    <MasterDetailPage.Master>

        <NavigationPage Title="Test">
            <x:Arguments>
                <local:MasterPage />
            </x:Arguments>
        </NavigationPage>

    </MasterDetailPage.Master>
1
votes

What can I do to make the StackLayout fill the whole MasterPage?

You could change the master default behavior. Try using the following code.

 this.MasterBehavior = MasterBehavior.SplitOnPortrait;

enter image description here