Bug 37438 - Grid is ignoring WidthRequest and HeightRequest inside content page
Summary: Grid is ignoring WidthRequest and HeightRequest inside content page
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-06 07:41 UTC by Dharmendar
Modified: 2017-11-17 15:47 UTC (History)
9 users (show)

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

Replication sample which contains the above mentioned case. (294.63 KB, application/zip)
2016-01-06 07:41 UTC, Dharmendar

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Dharmendar 2016-01-06 07:41:26 UTC
Created attachment 14460 [details]
Replication sample which contains the above mentioned case.

Grid WidthRequest and HeightReguest seem to be not working inside the content page.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace GridSample
    public class App : Application
        public App()
            // The root page of your application
            MainPage = new ContentPage
                //Grid as Direct child of content page
                //Both height request and width request is not working.
                Content = new Grid { BackgroundColor = Color.Green, WidthRequest = 300, HeightRequest = 300 }

        protected override void OnStart()
            // Handle when your app starts

        protected override void OnSleep()
            // Handle when your app sleeps

        protected override void OnResume()
            // Handle when your app resumes
Comment 1 Dharmendar 2016-01-08 05:03:18 UTC
MinimumHeightRequest and MinimumWidthRequest are also not working in Grid
Comment 2 Parmendra Kumar 2016-01-12 17:43:19 UTC
I have tried to reproduce this issue and able to reproduce this issue. To reproduce this issue I have followed the attached sample project.

Screencast: http://www.screencast.com/t/tL3K7pl2

DebugLog: https://gist.github.com/Parmendrak/d598069a9985e62a2734
IDE Log: https://gist.github.com/Parmendrak/778eafe5626df80eaf7a

Environment Info:

Microsoft Visual Studio Enterprise 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Enterprise

Xamarin (21aad62)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (50280e4)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (122b860)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 3 adrianknight89 2016-09-24 03:26:47 UTC
This doesn't make any sense to me. Normally, you'd expect the page content to cover the entire width and height of the screen. Why are you trying to create this kind of thing?
Comment 4 Dharmendar 2016-09-24 05:29:36 UTC
Hi Adrian,

Above code snippet provided is just to replicate the issue.In case if you are extending some custom view or custom control with grid and excepting to have certain height and width for the custom view or added grid as child of some other view(eg stack layout), it will not be layout with given height and width.  

Comment 5 Harikrishnan 2016-09-24 05:35:18 UTC
Hi Adrian,

What if we need to have more than one components laid out in a view? This makes sense in that case. 

And, those properties were exposed publically and hence is expected to work. If it is not working as stated or expected, then its a defect. rite?
Comment 6 Harikrishnan 2016-11-25 06:24:28 UTC
Hi Team,

Any update on this? Have this been fixed or considering in any of the latest releases?
Comment 7 Stephane Delcroix 2016-12-20 20:52:24 UTC
Width and Height Request are used when you pack views into layouts. They are used as request, and the layout system has no obligation to fulfill them.

As comment #3 says, the observed behavior is the correct one
Comment 8 Harikrishnan 2016-12-21 05:22:01 UTC
Hi @Stephene Delcroix,

Can you let me know when does the Xamarin layout system fulfill the Width and Height Request? 

I accept the layout system has no obligation to fulfill them, but under what scenario will it do so? If it will not do it any case, then what is the purpose of having those properties exposed publically? 

Am sorry I had to reopen this as I could not find any solid documentation stating the behavior for this.
Comment 9 Jason Smith [MSFT] 2017-06-16 17:25:13 UTC
Height/WidthRequest == "I would like to be AT LEAST this big"

MinimumHeight/WidthRequest == "I can not be smaller than this under any circumstances (fall off the edge of the screen before making me smaller than this)"

LayoutOptions.Fill == "Make me as big as the region my parent allocates for me"

Its the last one that is giving you trouble. A ContentPage always allocates its entire screen space to its child, and since the default option is fill the layout system then makes the child that size. Essentially pages act like a grid whose only child is in a *,* situation.

To make it force the grid to be a smaller size instead of setting your VerticalOptions/HorizontalOptions to Fill they need to be set to something else like Start/Center/End.

From a conceptual standpoint the problem is if you have a 1000x1000 screen and you make your grid 300x300 we dont know *where* to put the grid until you tell us. So by default we use Fill to avoid having to guess.