maui: [regression/7.0.81] Grid can't use star and auto together in version 7.0.81
Discussed in https://github.com/dotnet/maui/discussions/14519
Description
When you make a grid with a column(row)definition that is set to auto and another one that is set to *, and the grid is a child of a stacklayout the grid measurement calculations are wrong
Steps to Reproduce
- create a new MAUI project following the default template
- Replace the label with
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<BoxView Color="Red" WidthRequest="20"></BoxView>
<Label
Grid.Column="1"
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
</Grid>
- run the app and notice the label is not being shown at all
- change “auto” to 20 and run again, the label and boxview are shown correctly
These steps seems simple and clear enough, so I didn’t provide a repro project yet. If needed I can upload one later
Link to public reproduction project repository
https://github.com/tom-b-iodigital/maui-gridbug
Version with bug
7.0.81
Last version that worked well
7.0.59
Affected platforms
iOS, Android, I was not able test on other platforms
Affected platform versions
All versions
Did you find any workaround?
Setting the column defined with auto to a fixed width fixes the problem, however this is not always possible in complex layouts
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 12
- Comments: 24 (7 by maintainers)
We are facing the same issue, downgrading VS but the project is still on 7.0.81 I have put MauiVersion in csproj but nothing changes
<MauiVersion>7.0.59</MauiVersion>I can’t find a way to go back to workload 7.0.59 All my app entries, datepickers… are not showing right. Please help+1 this… [M]ulti-Platform [A]pp [U]ser [I]ssues continues to grow
Visual Studio Installer has rollback to previous version.
After some more testing it really seems like the changes to grid calculations should be reverted, all the heights and widths are off.
On a somewhat related note: does anybody know how to rollback the workloads to the previous version of Maui 🙄
I can confirm the same happens with
ColumnDefinitions="*,Auto"onWindows. The Auto column is not visible. Also the entire Grid is cut off height wise.Is there a timeframe for the next SR?
It is working again, with the property MauiVersion, I was still seeing the UI wrong even after rebuild, but after close VS, delete bin/obj and rebuild two times, It is now with 7.0.59. Thank you
@joseluisct Placing this property should work, at least it does for me… I didn’t have to downgrade Visual Studio for it… I also found this command line, but it does not seem to download the right version for me:
dotnet workload update --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/7.0.59.jsonWe are also facing grid layout issues after updating to the latest MAUI version. At least some are related to “Auto, *”, even though we don’t use StackLayout. I was not able to extract it to a simple repro app yet. For now, we are also rolling back to the previous version.
I got the workload back to 7.0.59 after downgrading both stable and preview VS. Although there seems to be other ways
https://github.com/dotnet/maui/issues/12998#issuecomment-1420484976
Update: this issue only occurs when the grid is a child of a stacklayout.
This seems to have been already known and tested
which makes it even stranger that this slipped through in an official release
While the next SR is not available: I downgraded to version 7.0.59 by using
<MauiVersion>7.0.59</MauiVersion>in the project file. This - as far as I can tell now - does not only work for local debug versions, but also for a release build I published to the google play console. I didn´t test IOS yet, but I hope that this will work too. I´m looking forward to the nuget solution @mattleibow was talking about. Hopefully the version desaster will then be a nightmare of the past…I spent a lot of time trying to figure out why, after upgrading to 7.0.81, the entire layout of my application floated in various places. Fortunately, I have experimentally established that the problem is with the Grid (separately and inside the CollectionView). Previously aligned elements floated, and the height of the elements in the CollectionView was calculated incorrectly. Since my application uses Grid both for tabular layout and for simulating layers, I came up with the following temporary solution until an update is released.
Create IValueConverter
Define global Grid style
This made it possible to set the RowDefinitions=“Auto” parameter for all Grids in the application where ColumnDefinitions (i.e. table layout) are defined and ignore all Grids that are used to simulate layers.
The RowDefinitions=“Auto” parameter in my case fixes problems with calculating the height of blocks. For lack of time, I have tested it so far only in Android. Please let me know if you can test it in iOS.
This is a duplicate of #13993. It’s been fixed in .NET 8 (https://github.com/dotnet/maui/pull/13999) and the fix has been backported to .NET 7 (https://github.com/dotnet/maui/pull/14165).
Unfortunately the SR release was already in motion by the time we backported the fix, and the process that should have updated the release did not function as intended. We’re looking into that. In the meantime, this will be fixed in the next release.
When I run
dotnet workload listI also still see 7.0.81I downgraded VS, also unistalled the app from emulator, run
dotnet workload restoreand right click solution file in VS and restore Nuget Packages. I am not sure if any of this steps made it running with the old version, I hope it’s working again for you.After using MauiVersion in the project file, and deleting bin/obj and rebuilding several times , etc. When run
dotnet workload listin the project directory, I still seeCould you please tell me what other steps if any that you did?
We’ve added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Update with a repro project https://github.com/tom-b-iodigital/maui-gridbug
yes, and it rolled back visual studio to 17.5.3 but left the workloads at 7.0.81
It is actually the initial calculations that are wrong. When resizing the window (not applicable for iPhone/Android) everything is recalculated roughly OK. I say rougly as my uniform margin
Grid.Margin="15"is not uniform at all.