Microsoft.Maui.Graphics
Microsoft.Maui.Graphics copied to clipboard
[Enhancement] Changes in Rectangle types
The issue
Using Rectangle from XAML creates a Shape by default. However, to set position and size we sometimes need to use Rectangle struct from Microsoft.Maui.Graphics.
Although it is possible to do it from C#, not from XAML.
<ContentPage.Resources>
<ResourceDictionary>
<!-- This is a Shape -->
<Rectangle x:Key="Rectangle" />
</ResourceDictionary>
</ContentPage.Resources>
<!-- Here we need a Microsoft.Maui.Graphics.Rectangle type -->
<ScrollView AbsoluteLayout.LayoutBounds="{StaticResource Rectangle}" />
Because we have more than one Rectangle type. See issue https://github.com/dotnet/maui/issues/3022 for more information
Proposal
Rename Rectangle
and RectangleF
to Rect
and RectF
. In this way we would have two different types with different names avoiding the problem. We could look for other alternative options but they would require the use of aliases or similar.
No current plans for this, MAUI itself uses the Rectangle types from MAUI Graphics already.
There's a more edge case where in XAML you have to be a bit more specific if you want to use the MAUI Graphics Rectangle vs the MAUI Shapes Rectangle, but that has a workaround.
Closing.
https://github.com/dotnet/maui/issues/4720