Bug 25718 - ListView's "VerticalOptions" set to "Center" doesn't work
Summary: ListView's "VerticalOptions" set to "Center" doesn't work
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-05 13:34 UTC by Simon Villiard
Modified: 2016-04-08 18:46 UTC (History)
5 users (show)

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

ListView OnSizeRequest method override (22.94 KB, image/png)
2015-01-05 13:34 UTC, Simon Villiard
Expected layout with Xamarin.Forms 1.2.3 (80.73 KB, image/png)
2015-01-26 09:35 UTC, Simon Villiard
Same layout as the other one, but with Xamarin.Forms 1.3 (74.10 KB, image/png)
2015-01-26 09:45 UTC, Simon Villiard
The XAML Layout (27.23 KB, image/png)
2015-01-26 09:46 UTC, Simon Villiard

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 Simon Villiard 2015-01-05 13:34:24 UTC
Created attachment 9240 [details]
ListView OnSizeRequest method override

Even if the "VerticalOptions" of the ListView is set to "Center", the ListView height won't wrap its content. Instead of doing the expected behavior, the ListView will unexpectedly have a minimum height even if we haven't specified one. 

Here's what I found when I peeked into the Xamarin.Forms 1.3 DLL:

There's a different method override since the last version which is:

protected override SizeRequest OnSizeRequest (double widthConstraint, double heightConstraint)
	Size minimum = new Size (40, 40);
	double width = Math.Min (Device.Info.ScaledScreenSize.Width, Device.Info.ScaledScreenSize.Height);
	IList list = base.ItemsSource as IList;
	Size request;
	if (list != null && !this.HasUnevenRows && this.RowHeight > 0 && !this.IsGroupingEnabled) {
		request = new Size (width, (double)(list.Count * this.RowHeight));
	else {
		request = new Size (width, Math.Max (Device.Info.ScaledScreenSize.Width, Device.Info.ScaledScreenSize.Height));
	return new SizeRequest (request, minimum);

I'm not 100% sure, but I have a strong feeling that the bug could be fixed by modifying or removing this method override.
Comment 1 Arpit Jha 2015-01-14 03:59:52 UTC
We have checked this issue and able to reproduce this  issue with the help of bug description.

Steps i have followed to reproduce this issue.
1.Create a xamarin.forms application.
2. Update xamarin.forms version to
3.Set visibility dropdown to All public members in assembly browser.
4.Search method 'OnSizeRequest' in assembly browser from Assembly browser->Xamarin.forms->Listview.
5.Observed that OnSizeRequest is present in xamarin.froms
6.Update xamarin.forms version to
7.Search method 'OnSizeRequest' in assembly browser.
8.Observed that OnSizeRequest is not present in xamarin.froms

Please let me know if i missed anything to reproduce this issue ? 

Environment Info:
=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6602)
Build 6A1052c

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: dfb682f
Build date: 2015-01-08 13:39:32-0500

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Mac OS X 10.10.0
Darwin mac360-xamarins-Mac-mini.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Arpit Jha 2015-01-14 04:51:59 UTC
An update to comment  1

Screencast : http://www.screencast.com/t/7skUCDYJH
Comment 3 Jason Smith [MSFT] 2015-01-26 05:14:05 UTC
Can you please explain to me the layout you wish to have? The method override is there for a reason (primarily to resolve issues people are having with size negotiation of ListViews inside of relatively stupid layouts like scrollviews)
Comment 4 Simon Villiard 2015-01-26 09:35:49 UTC
Created attachment 9497 [details]
Expected layout with Xamarin.Forms 1.2.3
Comment 5 Simon Villiard 2015-01-26 09:45:07 UTC
Created attachment 9499 [details]
Same layout as the other one, but with Xamarin.Forms 1.3
Comment 6 Simon Villiard 2015-01-26 09:46:23 UTC
Created attachment 9500 [details]
The XAML Layout
Comment 7 Paul DiPietro [MSFT] 2016-04-08 18:46:11 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team