Bug 45266 - RelativeLayout: setting a height constraint relative to another item does not work
Summary: RelativeLayout: setting a height constraint relative to another item does not...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
Depends on:
Reported: 2016-10-11 06:12 UTC by softlion
Modified: 2017-06-21 13:38 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Reproduction project (343.59 KB, application/x-zip-compressed)
2017-03-27 01:27 UTC, Paul DiPietro [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 45266 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description softlion 2016-10-11 06:12:07 UTC
A repro layout looks like this:

          <BoxView x:Name="TopLayout"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
          <Grid x:Name="TheGrid" BackgroundColor="Yellow" VerticalOptions="End" HorizontalOptions="Fill" 
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=TopLayout, Property=Height, Factor=1}"

The height constraint in TheGrid is ignored.
The only workaround found after 6 hours is to override LayoutChildren in the page and force TheGrid's height:

       protected override void LayoutChildren(double x, double y, double width, double height)
            base.LayoutChildren(x, y, width, height);

            //Force TheGridto have the same height as TopLayout
            //This does not work in Xaml as of 2016-10-11
            if (TheGrid.HeightRequest != TopLayout.Height)
                TheGrid.HeightRequest = TopLayout.Height;
Comment 1 Paul DiPietro [MSFT] 2017-03-27 01:27:10 UTC
Attaching a proper reproduction project until I can get some feedback on this behavior.
Comment 2 Paul DiPietro [MSFT] 2017-03-27 01:27:30 UTC
Created attachment 20851 [details]
Reproduction project