maui
maui copied to clipboard
VerticalOptions cannot be set on a Rectangle in Windows
Description
I'm having a Grid with a fixed size and a background color. Inside that I'm trying to draw a Rectangle from the bottom (like a vertical progress bar). This works as expected in Android. But in Windows the inner rectangle always fills the Grid. Drawing the inner rectangle with a Grid solves the problem.
This is from Windows:

And this is from Android:

The left progress bar is draw with two Grids, the right one with a Grid and a Rectangle.
Steps to Reproduce
- Create a new MAUI app.
- Replace the MainPage.xaml with this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiIssues.MainPage">
<HorizontalStackLayout
Spacing="25"
Padding="30,30"
VerticalOptions="Start"
>
<!-- This works fine -->
<Grid WidthRequest="100" HeightRequest="200" BackgroundColor="{StaticResource Gray600}">
<Grid
HeightRequest="50"
VerticalOptions="End"
BackgroundColor="{StaticResource Blue100Accent}"
/>
</Grid>
<!-- This is fine on Android, but not on Windows -->
<Grid WidthRequest="100" HeightRequest="200" BackgroundColor="{StaticResource Gray600}">
<Rectangle
HeightRequest="50"
VerticalOptions="End"
BackgroundColor="{StaticResource Blue200Accent}"
/>
</Grid>
</HorizontalStackLayout>
</ContentPage>
Full sample: https://github.com/pekspro/MauiIssues/tree/7573_VerticalOptions_Rectangle_Windows
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows, I was not able test on other platforms
Affected platform versions
Windows SDK 10.0.171340.0
Did you find any workaround?
Use Grid instead of Rectangle.
Relevant log output
No response
verified repro on windows with above project.
I've updated sample application to .NET 7. The same issue remains.
Verified this on Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on Windows 11 with below Project: 7573.zip
Hi @pekspro. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.