How to bind AbsoluteLayout.LayoutBounds in XAML

I am trying to bind AbsoluteLayout.LayoutBounds in XAML, but i'm not sure exactly how to get it to work. Anyone know how to accomplish this?

Here is my code so far:

    <BoxView BackgroundColor="Red" HeightRequest="40" AbsoluteLayout.LayoutBounds="{Binding ProgessBounds}" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" />
public Rectangle ProgressBounds {
    get {
        return new Rectangle (0.5f, 0.5f, MyWidthVariable, AbsoluteLayout.AutoSize);


  • JoshuaNovakJoshuaNovak USMember ✭✭

    Anyone? :(

  • JoshuaNovakJoshuaNovak USMember ✭✭


  • YkshLeoYkshLeo USMember ✭✭✭✭


    Try this,

    AbsoluteLayout.LayoutBounds="{Binding ProgessBounds, Mode=OneWay}"

    Refer this forum post.

  • JoshuaNovakJoshuaNovak USMember ✭✭

    @Yksh.Leo That doesn't work. The issue is the ProgressBounds doesn't seem to register at all. I'm not sure if i'm supposed to return a rectangle, a string, or something else when I'm binding it in XAML. The forum talks about Binding a variable, but never says what that variable actually is.

  • threadythready CAMember ✭✭✭

    @JoshuaNovak - did you ever figure this one out? I'm also interested in getting this going. I'll let you know if I get it...

  • JoshuaNovakJoshuaNovak USMember ✭✭

    @MikeGagnon Yes I did. I was right the first time. Not sure why it didn't work before, but it started working eventually. I think what you have to keep an eye on is how your binding is setup.

  • threadythready CAMember ✭✭✭

    Great, thanks @JoshuaNovak

  • Emixam23Emixam23 USMember ✭✭✭

    I can't figure it out... I don't understand how can I set the layoutBounds from a bindable property defined in the C# side

  • FreefragFreefrag USMember ✭✭

    Which type was correct? Rectangle? or another?

  • The correct Type is a Rectangle to use with that binding for AbsoluteLayout. Like this:

    <Frame AbsoluteLayout.LayoutBounds="{Binding Path=TopBorder}" AbsoluteLayout.LayoutFlags="All"/>

    And in Backing cs file:

    public static readonly BindableProperty TopBorderProperty = BindableProperty.Create("TopBorder", typeof(Rectangle), typeof(ContentView), new Rectangle(0, 0, 1, 0.05));
    public Rectangle TopBorder
       get { return (Rectangle)GetValue(TopBorderProperty); }
       set { SetValue(TopBorderProperty, value); }
  • 74hakansukur74hakansukur Member ✭✭

    Huh it is an old post. I guess the LayoutBounds needs a Xamarin.Forms.Rectangle object:

    double x,y,width,height;
    x= 100;
    width = 100;
    height = 100;
    Xamarin.Forms.Rectangle rect = new Xamarin.Forms.Rectangle(x,y,width,height);

    and in XAML:

    <Frame AbsoluteLayout.LayoutBounds="{Binding rect}" AbsoluteLayout.LayoutFlags="All"/>

    It works for me in 2018 in VS2017.

Sign In or Register to comment.