question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grid default child layout changed

See original GitHub issue

Description

Moving from .NET Maui 7.0.0-rc.1 to 7.0.0-rc.2 seems to have introduced a significant change in Grid behavior. In previous builds (including Maui 6.0), children of Grid seemed to default to LayoutOption.Fill behaviors, but in rc2, child elements that do not have an explicit HorizontalOptions or VerticalOptions seem to be appearing in the upper-left corner of a cell.

The problem may be even worse, because if I try to add explicit Fill values for HorizontalOptions and VerticalOptions (a potential workaround), the problem does not seem to go away!

Steps to Reproduce

  1. Create a new .NET Maui app.
  2. In the default ContentPage, page the content below.
  3. When executed in 7.0.0-rc.1 or earlier, you will see that the “pink label” will fill the entire 36x36 rectangle and you won’t see any of the “aqua” background. When viewed in 7.0.0-rc.2, the label appears in the upper-left corner.
  4. EVEN WORSE… if you add HorizontalOptions=“Center” and VerticalOptions=“Center”, the label does not move!

Content:

    <Grid BackgroundColor="Aqua" HeightRequest="36" WidthRequest="36">
        <Label FontSize="20" BackgroundColor="Pink" VerticalTextAlignment="Center" 
           HorizontalTextAlignment="Center" >A</Label>
    </Grid>

Link to public reproduction project repository

(Not public)

Version with bug

7.0 Release Candidate 2

Last version that worked well

7.0 Release Candidate 1

Affected platforms

iOS, Windows

Affected platform versions

Windows SDK 10.0.17763.0, iOS 16

Did you find any workaround?

No. Even if the defaults had changed, I would have expected that explicitly setting HorizontalOptions and VeritcalOptions would have worked… but it did not! I’m not aware of a workaround.

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
PureWeencommented, Oct 20, 2022

This will be fixed by #10768

0reactions
wkfrycommented, Nov 2, 2022

@PureWeen: this is still repro-ing in .NET 7.0.100-rc.2.22477.23 (Visual Studio Version 17.4.0 Preview 6.0). Is that expected?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make a GridLayout to change its children views ...
I'm using a GridLayout of Views. Each cell is of the same size, and contains just a simple TextView that should change its...
Read more >
Basic concepts of grid layout - CSS: Cascading Style Sheets
I have now created a grid with three 200-pixel-wide column tracks. The child items will be laid out on this grid one in...
Read more >
Grid
To change the alignment of a single grid child, select the grid child and go to Style panel > Grid child > Align....
Read more >
GridPane (JavaFX 8)
If row/column spans are not set, they will default to 1. A child's placement constraints can be changed dynamically and the gridpane will...
Read more >
Xamarin.Forms Grid
The Grid is a layout that organizes its children into rows and columns, which can have proportional or absolute sizes. By default, a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found