Maui for android community toolkit popup size issue

Haviv Elbsz 2,091 Reputation points
2023-12-11T19:27:01.19+00:00

Hello all. Maui ver 17.9 preview emulator ver 34. Please how I can access the popup size property. programmatically and change the size.x to screen width. thank you very much

<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
           xmlns:mct="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
           x:Class="RazKmoShed.PopupPage"
           CanBeDismissedByTappingOutsideOfPopup="False"
           Size="300, 500">
Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-12-12T03:00:18.3633333+00:00

    Hello,

    how I can access the popup size property. programmatically and change the size.x to screen width.

    You can access the size by the PopupPage.Size, before you popup your page.

    And you can change the size.x to screen width, you can do it by popup.Size=new Size(this.Width, 500);

    Please refer to the following code. I tested it in the button click's background code.

    private async void OnCounterClicked(object sender, EventArgs e)
    {
         var popup = new PopUpPage();
         Size OrignalSize = popup.Size;
       
         popup.Size=new Size(this.Width, 500);
         var result = await this.ShowPopupAsync(popup);
    }
    

    Best Regards,

    Leon Lu


    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.