FillAndExpand is not Working in Net Maui Popup

Yusuf 791 Reputation points
2022-08-31T09:16:08.197+00:00

Hi,
I get a trimmed Popup in Android

<?xml version="1.0" encoding="utf-8" ?>  
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"  
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
              xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"  
             x:Class="MyApp.TestPopup">  
      
    <VerticalStackLayout x:Name="popupLayout" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">  
        <HorizontalStackLayout>  
            <Label  x:Name="label" Text="This is a very important message! Do you agree?" />  
            <Button Text="Yes"   
                Clicked="OnYesButtonClicked" BackgroundColor="DeepPink"/>  
            <Button Text="No"  
                Clicked="OnNoButtonClicked" BackgroundColor="DeepSkyBlue"/>  
        </HorizontalStackLayout>  
  
    </VerticalStackLayout>  
</toolkit:Popup>  

236513-screenshot-1.png

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-09-05T02:52:49.15+00:00

    Hello,

    As you mentioned, you need to use Size property to change the size of Popup Page.

    Size:
    Gets or sets the Size of the Popup Display. The Popup will always try to constrain the actual size of the Popup to the size of the View unless a Size is specified. If the Popup uses the HorizontalOptions or VerticalOptions properties that are not the defaults then this Size property is required.

    Therefore, you need to set the width and height into the size property to change it, please refer to the following content:

    In C#:

       this.Size = new Microsoft.Maui.Graphics.Size(400,1000);  
    

    In XAML:

       Size="400,1000"  
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.