Bug 21379 - Grid ignores GridUnitType.Star
Summary: Grid ignores GridUnitType.Star
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 21398 ()
Depends on:
Blocks:
 
Reported: 2014-07-16 15:38 UTC by John Miller [MSFT]
Modified: 2014-07-22 15:41 UTC (History)
6 users (show)

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


Attachments
Android Screenshot Version 1.2.1 (27.23 KB, image/png)
2014-07-16 15:38 UTC, John Miller [MSFT]
Details
Android Screenshot Version 1.0.6186 (28.95 KB, image/png)
2014-07-16 15:38 UTC, John Miller [MSFT]
Details
iOS Screenshot Version 1.0.6186 (15.56 KB, image/png)
2014-07-16 15:39 UTC, John Miller [MSFT]
Details
iOS Screenshot Version 1.2.1 (15.66 KB, image/png)
2014-07-16 15:39 UTC, John Miller [MSFT]
Details
Source code for the page (10.12 KB, text/plain)
2014-07-22 12:45 UTC, Eric Grover
Details
iOS Page with Broken grid layout (200.29 KB, image/png)
2014-07-22 12:45 UTC, Eric Grover
Details
Android page with broken grid layout. (190.45 KB, image/png)
2014-07-22 12:46 UTC, Eric Grover
Details
Grid using * under 1.0.6186 (291.03 KB, image/png)
2014-07-22 12:54 UTC, rwakelan
Details
Grid using * under 1.2.2.6240-pre2 (122.35 KB, image/png)
2014-07-22 12:55 UTC, rwakelan
Details
Simple Reproduction of bug. (63 bytes, text/plain)
2014-07-22 12:57 UTC, rwakelan
Details


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:
Status:
RESOLVED INVALID

Description John Miller [MSFT] 2014-07-16 15:38:27 UTC
Created attachment 7396 [details]
Android Screenshot Version 1.2.1

### Overview: 

    After updating to 1.2.1.6229, Grid does not layout the example the same. It looks like it is ignoring GridUnitType.Star. 

### Steps to Reproduce: 

    1. Run the attached sample project
    2. Observe the spacing on the right-hand side of the blue rectangle. 

### Actual Results: 

    I have attached 4 screenshots to illustrate the difference better. Please compare the iOS/Android images with a prefix of 
_106186" (XF version 1.0.6186) to the images with a prefix of "_1216229" (XF version 1.2.1.6229). There is a noticeable gap in the layout spacing on the right hand side.

### Expected Results: 

    The same behavior in layout as experienced in version 1.0.6186.

### Build Date & Platform: 

    XF 1.2.1.6229
Comment 1 John Miller [MSFT] 2014-07-16 15:38:56 UTC
Created attachment 7397 [details]
Android Screenshot Version 1.0.6186
Comment 2 John Miller [MSFT] 2014-07-16 15:39:19 UTC
Created attachment 7398 [details]
iOS Screenshot Version 1.0.6186
Comment 3 John Miller [MSFT] 2014-07-16 15:39:39 UTC
Created attachment 7399 [details]
iOS Screenshot Version 1.2.1
Comment 4 John Miller [MSFT] 2014-07-16 15:42:00 UTC
Created attachment 7400 [details]
TestCase
Comment 5 Eric Grover 2014-07-17 14:09:07 UTC
*** Bug 21398 has been marked as a duplicate of this bug. ***
Comment 6 Eric Maupin 2014-07-22 10:48:49 UTC
The repro case does not actually use the grid that is set up, instead creating a new one with default sizing.
Comment 7 Eric Grover 2014-07-22 10:59:32 UTC
Why was this bug closed?  This is clearly a defect.  This bug makes the current version of XForms unusable.
Comment 8 rwakelan 2014-07-22 11:29:14 UTC
That's a very good question, Eric Grover. This is absolutely a bug in the current version of Xamarin.Forms. The only reason I can think of is that Xamarin didn't want to actually look into the problem, which is very frustrating.  I cannot release an app because of this bug.
Comment 9 Eric Maupin 2014-07-22 12:36:17 UTC
This was closed because the test case provided does not demonstrate a bug. The outer grid does not specify any columns, the default column width is Auto, therefore the inner grids are only as big as they need to be inside of the outer grid. If you have a valid test case to demonstrate this same issue, please post it.
Comment 10 Eric Grover 2014-07-22 12:43:51 UTC
This is infuriating.  I originally submitted this issue with the documentation I am about to post here.  The fact that John Miller might have made a mistake in the way he posted the "repro" that he created should not be an excuse to close out a bug like this.  You should contact follow back with the person who submitted it for more information at the very least.  I agree with the previous post that says it looks like you don't really want to look into problems.  We are paying large sums of money for you to look into these bugs.

Here is my original "repro" as you refer to it.  My code and screen shots will follow this post.
Comment 11 Eric Grover 2014-07-22 12:45:12 UTC
Created attachment 7449 [details]
Source code for the page

This is the source for the page that renders the screen shots that are also being attached.  Please let me know if you would like me to zip up the full solution.
Comment 12 Eric Grover 2014-07-22 12:45:50 UTC
Created attachment 7450 [details]
iOS Page with Broken grid layout

iOS Page with Broken grid layout/
Comment 13 Eric Grover 2014-07-22 12:46:36 UTC
Created attachment 7451 [details]
Android page with broken grid layout.

Android page with broken grid layout.
Comment 14 rwakelan 2014-07-22 12:54:50 UTC
Created attachment 7452 [details]
Grid using * under 1.0.6186
Comment 15 rwakelan 2014-07-22 12:55:14 UTC
Created attachment 7453 [details]
Grid using * under 1.2.2.6240-pre2
Comment 16 Eric Grover 2014-07-22 12:56:14 UTC
BTW, this is not the way that Grids behave in WPF/Silverlight/WinStore XAML.  If no column is specified, the grid will by default take up the available width of its parent container.  That is the way it was working in previous versions of XForms as well.
Comment 17 rwakelan 2014-07-22 12:57:02 UTC
Created attachment 7454 [details]
Simple Reproduction of bug.
Comment 18 Eric Maupin 2014-07-22 12:59:17 UTC
Your repro has the same issue, it lies here:

var scoreContainer = new Grid {
    BackgroundColor = AppColors.DarkContainer,
    Children = { scorePanel }
};

Unfortunately, you got the "correct" behavior originally because of a bug. Grids were asking for an infinite amount of space when being sized. So, even though the default column with is Auto, given an infinite amount of space requested, it will fill the space. The infinite size request bug was fixed and now your layout is incorrect because it relied on that bug.

In the above snippet, there are no column definitions specified, which means it's creating one by default with a size of "Auto". This means that the contents will only take as much room as they need to. Now that it's properly measuring, you can see that this is exactly what it does. If you add a column definition to `scoreContainer` with a size of *, you will get the layout you expect.

(In reply to comment #16)
> BTW, this is not the way that Grids behave in WPF/Silverlight/WinStore XAML. 
> If no column is specified, the grid will by default take up the available width
> of its parent container.

We know, this was an unfortunate decision that unfortunately we're stuck with.
Comment 19 rwakelan 2014-07-22 13:01:50 UTC
I've also attached a reproduction of the bug as well as screenshots under different versions of Xamarin.Forms.  This test case is nothing more than a page containing a grid of six box views.  This is as dead simple as it gets.

My question to you is this: Why do we pay a subscription to use this tool when you cannot take 5 minutes to look into a bug.  That is how long it took me to make that test case.  That includes the screen shots.  The description of the bug tells you exactly what is wrong: * is ignored in grids.  It shouldn't be that hard to make a sample test case when the original submission has a technical flaw to test it out.

So, when we feel that Xamarin is not living up to it's end of the bargain, who do we contact? Because I would like to know who to talk to when I feel that Xamarin isn't even trying to take bugs seriously.
Comment 20 Eric Grover 2014-07-22 13:03:01 UTC
I see, it's not a bug.  It's a feature.
Comment 21 Eric Maupin 2014-07-22 15:41:03 UTC
(In reply to comment #19)
> I've also attached a reproduction of the bug as well as screenshots under
> different versions of Xamarin.Forms.  This test case is nothing more than a
> page containing a grid of six box views.  This is as dead simple as it gets.

The issue with your test case is that you're setting the Horizontal and VerticalOptions of the containing grid to non-fill settings. If you simply remove these setters (or set them to Fill), you'll get the behavior from your 1.0 screenshot.

The reason for this is that with a non-fill horizontal and vertical options, you're telling the Grid that it needs to measure how big it needs to be. So, it measures the BoxViews which are each 40x40. Therefore, with these sizes and the spacing, it determines the Grid size. Then, out of that size (which is 120+spacing), each of the columns are sized evenly as per the star layout.

> So, when we feel that Xamarin is not living up to it's end of the bargain, who
> do we contact? Because I would like to know who to talk to when I feel that
> Xamarin isn't even trying to take bugs seriously.

Please feel free to contact Joseph Hill: jhill@xamarin.com