0

I have the following XAML:

<Path Style="{StaticResource squared}"
        AbsoluteLayout.LayoutFlags="All"
        AbsoluteLayout.LayoutBounds="-.2, .2, .3, .3" />

<Path  Style="{StaticResource squared}"
        AbsoluteLayout.LayoutFlags="All"
        AbsoluteLayout.LayoutBounds="1.1, .7, .3, .3" />

<Path Style="{StaticResource squared}"
        AbsoluteLayout.LayoutFlags="All"
        AbsoluteLayout.LayoutBounds="-.1, .9, .3, .3" />

Since the height and width are the same, I was trying to set them via a static resource.

<x:Decimal x:Key="SquareSize">.3</x:Decimal>

However, I don't see a way to use it and pass only the height and width. I have tried something like this:

<AbsoluteLayout.LayoutBounds>
    <Rect>
        <Rect.X>-.2</Rect.X>
        <Rect.Y>.2</Rect.Y>
        <!--No way to assign a static resouce below--> 
        <Rect.Height />
        </Rect>
</AbsoluteLayout.LayoutBounds>
Neville Nazerane
  • 6,622
  • 3
  • 46
  • 79

1 Answers1

-1

AbsoluteLayout.LayoutBounds needs a Xamarin.Forms.Rectangle object.

You can refer to the following code:

        <x:Double x:Key="myWidth">100</x:Double> 
        <x:Double x:Key="myHeight">100</x:Double>

        <Rectangle x:Key="mRectangle" 
                   WidthRequest="{StaticResource myWidth}"      
                   HeightRequest="{StaticResource myHeight}"
               > 
        </Rectangle>

And bind it as follows:

    <Frame  AbsoluteLayout.LayoutBounds="{Binding mRectangle}" 
            AbsoluteLayout.LayoutFlags="All" BackgroundColor="Yellow">
        
    </Frame>
Jessie Zhang -MSFT
  • 9,830
  • 1
  • 7
  • 19