RelativeLayout in Xaml - BoxViews in each corner

ScottBradleyScottBradley AUMember ✭✭

Is it possible to do this entirely in xaml?

            // Four BoxView's
            relativeLayout.Children.Add(
                new BoxView { Color = Color.Red },
                Constraint.Constant(0),
                Constraint.Constant(0));

            relativeLayout.Children.Add(
                new BoxView { Color = Color.Green },
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Width - 40;   
                }),
                Constraint.Constant(0));

            relativeLayout.Children.Add(
                new BoxView { Color = Color.Blue },
                Constraint.Constant(0),
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height - 40;
                }));

            relativeLayout.Children.Add(
                new BoxView { Color = Color.Yellow },
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Width - 40;
                }),
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height - 40;
                }));

I tried to add the BoxViews with a name and then modify the Constraints in the code behind but that also didn't work

Best Answer

Answers

Sign In or Register to comment.