Microsoft.Maui.Graphics icon indicating copy to clipboard operation
Microsoft.Maui.Graphics copied to clipboard

[Enhancement] Changes in Rectangle types

Open jsuarezruiz opened this issue 3 years ago • 2 comments

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.

jsuarezruiz avatar Oct 20 '21 11:10 jsuarezruiz

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.

Redth avatar Jan 19 '22 17:01 Redth

https://github.com/dotnet/maui/issues/4720

StephaneDelcroix avatar Feb 17 '22 08:02 StephaneDelcroix