Forum Xamarin.Forms

Moving Grid within AbsoluteLayout

Daniel.RDaniel.R USMember ✭✭
edited July 2016 in Xamarin.Forms

Hi guys,

i would like to change the positon of an underlying Absolute Layout.

My structure is like this:

<AbsoluteLayout (mainLayout)>
        <Grid (mainGrid)>
    <AbsoluteLayout (subLayout)>
        <Grid (subGrid)>

The subGrid grid is very long, so that i can see only one cell - that's what I want, that's ok.
But now i would like to move the grid to see another cell. How can i do this?
And is this done by setting the LayoutBounds?

My Code for subgrid:

// init
subGrid = new Grid
    RowDefinitions =
            new RowDefinition { Height = GridLength.Auto }
AbsoluteLayout.SetLayoutFlags(subGrid, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(subGrid, new Rectangle(0, 0,64, 1));

// moving
AbsoluteLayout.SetLayoutBounds(subGrid, new Rectangle(currentIndex, 0, 1, 1));

Unfortunately nothing happens on changing the x-Values of the new Rectangle. Is it possible to use negative Values?

Sign In or Register to comment.