-
Notifications
You must be signed in to change notification settings - Fork 472
[Enhancement] Automatically resize the popup depending on the content #937
Comments
This would be great to have! |
I think a lot of people want this, not sure how easy it is to implement though |
Thanks! However, we are no longer adding new features to Xamarin Community Toolkit, focusing on the .NET MAUI Community Toolkit. Please open a New Feature Discussion to implement this feature in the .NET MAUI Community Toolkit. I've posted more information about the Future Of Xamarin Community Toolkit here: https://devblogs.microsoft.com/xamarin/the-future-of-xamarin-community-toolkit/?WT.mc_id=mobile-0000-bramin |
Hello! If someone still facing this, I did the following workaround in my application: Once you set these sizes use this code in the Popup page constructor:
I'm using const value for width but it also works at the same way. |
My Popup page looks something like this: <ScrollView>
<Grid x:Name="MainContentGrid" RowDefinitions="auto, auto, auto">
... And in my constructor, I did this, which seems to work: public MyPopup()
{
InitializeComponent ();
BindingContext = this;
Size = new Size(300, MainContentGrid.Height + MainContentGrid.Height);
} Strangely, it does not work properly unless I add that 2nd I don't really understand this though. When debugging, the value of EDIT: If there is too much content inside the grid, it will overflow on the page. |
I just want to provide some information as @kelltom gave me some idea. I am working with Android, have to test this for iOS later on. I had a Popup which was scaling semi-correclty. Meaning: it was scaling however long-ish label texts did not work properly. I changed the Popup Size height from 0 to -1: Previous configuration, not fully working: New size configuration, working with larger label texts |
Summary
Currently the Popup has its own dimension independent of the content; for example, on Android the popup almost completely fills the height of the screen. It would be useful if the popup could resize according to the content so as to take up as little space as possible on the display.
API Changes
I am not sure which APIs to use for this request. In my opinion, what I requested could be the default: if instead there is the need to have dimensions other than the minimum required by the content, the programmer can use the "Size" property to modify them.
If instead you want to keep the current default, you could use a new bool "Autosize" property which, if set to true, resizes the popup with respect to the content
Intended Use Case
If you wanted to replace the DisplayAlert method with the Popup to display a simple title, a message with an "ok" or "ok" and "cancel" button, having a popup that resized itself according to the length of the message would be very useful
Who Will Do The Work?
The text was updated successfully, but these errors were encountered: