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.

MaximumWidthRequest in FlexLayout is not working on macOS or iOS

See original GitHub issue

Description

The MaximumWidthRequest property on the FlexLayout should request a maximum width. On Windows, it works the way I’d expect it to. It doesn’t seem to work at all on macOS. I confirmed this is an issue on both Intel and M2 Macs, and according to @jknaudt21’s comment it’s also an issue on iOS.

Button BorderColor property is also not working correctly.

MAUI version:

% dotnet workload list

Installed Workload Id      Manifest Version      Installation Source
--------------------------------------------------------------------
maui-maccatalyst           7.0.59/7.0.100        SDK 7.0.200        
maui-ios                   7.0.59/7.0.100        SDK 7.0.200        
maui-android               7.0.59/7.0.100        SDK 7.0.200 

Here’s an example. This XAML code renders 16 buttons with WidthRequest=“100” inside a FlexLayout with MaximumWidthRequest=“400”:

     <FlexLayout Wrap="Wrap" MaximumWidthRequest="400">
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
       <Button BackgroundColor="LightBlue" BorderColor="Black" HeightRequest="100" WidthRequest="100" FontSize="60" />
     </FlexLayout>

On Windows this renders exactly the way I expect it to:

image

When I resize the window so it’s smaller than 400 wide, the buttons wrap as expected.

On macOS using Visual Studo 17.6 Preview (17.6 build 402) installed on clean machine, it looks like this:

image

The MaximumWidthRequest property seems to be ignored, and the buttons wrap as if it’s not there.

Also, it looks like the BorderColor="Black" property in the buttons is being ignored.

Steps to Reproduce

  1. Create a new .NET MAUI app in macOS on an M1 or M2 Mac
  2. Paste the XAML from the description into MainPage.xaml
  3. Run the app

Link to public reproduction project repository

https://github.com/andrewstellman/reproduce-maui-bug

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOS 13.2.1 (22D68)

Did you find any workaround?

No, sadly.

Relevant log output

No response

Issue Analytics

  • State:open
  • Created 7 months ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewstellmancommented, Mar 26, 2023

Unfortunately, I haven’t found a workaround. 😢 Hopefully this bug will get fixed soon!

2reactions
jknaudt21commented, Mar 1, 2023

Adding more to the discussion, it seems that iOS is also affected by this bug. The flex layout doesn’t seem “right”: image.

I’m also creating a separate issue to track the issues with the borders not displaying correctly. See: https://github.com/dotnet/maui/issues/13612

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlexLayout - not working so great : r/dotnetMAUI
Hey guys. I just put together an app which displays image thumbnails. Made the most sense to use a flexlayout inside a ScrollView...
Read more >
Unable to use FlexLayout in a BindableLayout with MAUI
I just retested with a FlexLayout as the bindable object and a Stacklayout displaying the bindable variables. Everything works fine on the ...
Read more >
Untitled
NET MAUI podcast app starts in under 240ms on modern iPhone and iPad ... 1 d., · MaximumWidthRequest in FlexLayout is not working...
Read more >
Flex Layout in .NET MAUI - YouTube
NET MAUI Work with the toolbar Share NEWS on Social Media Prerequisites In ... the IOS device and MacBook and this limitation are...
Read more >
FlexLayout - .NET MAUI
The .NET MAUI FlexLayout is a layout that stacks or wraps a collection of child views.
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