Bug 34927 - LayoutChildren method on Layout class does not get called on iOS
Summary: LayoutChildren method on Layout class does not get called on iOS
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 1.5.0
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-10-16 02:37 UTC by Prashant Cholachagudda
Modified: 2015-10-16 03:13 UTC (History)
2 users (show)

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


Attachments
Test case (176.18 KB, application/zip)
2015-10-16 02:37 UTC, Prashant Cholachagudda
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 ANSWERED

Description Prashant Cholachagudda 2015-10-16 02:37:06 UTC
Created attachment 13361 [details]
Test case

In the attached sample the LayoutChildren method on Layout class does not get called on iOS.
On Android this works perfectly, and renders perfectly On iOS we get a blank screen, and a breakpoint reveals that LayoutChildren is not being called. 

# Code snippet

	public class MyLayout : Layout<View>
	{
		public MyLayout ()
		{
			Children.Add (new Label { Text = "Label1", BackgroundColor = Color.Red });
			Children.Add (new Label { Text = "Label2", BackgroundColor = Color.Red });
			Children.Add (new Label { Text = "Label3", BackgroundColor = Color.Red });
			Children.Add (new Label { Text = "Label4", BackgroundColor = Color.Red });
		}

		protected override void LayoutChildren (double x, double y, double width, double height)
		{
			for ( int i=0 ; i< 4 ; i++ ) 
			{
				Rectangle layoutBounds = new Rectangle (0, i * 40, 200, 40);
				Children [i].Layout (layoutBounds);
			}
		}
	}

Xaml:
	<?xml version="1.0" encoding="UTF-8"?>
	<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
				 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
				 xmlns:controls="clr-namespace:LayoutTest;assembly=LayoutTest"
				 x:Class="LayoutTest.MyPage">
		<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
			<controls:MyLayout />
		</StackLayout>
	</ContentPage>
Comment 1 Stephane Delcroix 2015-10-16 03:11:01 UTC
you might want to override OnSizeRequest () too.
Comment 2 Jason Smith [MSFT] 2015-10-16 03:13:10 UTC
Stephane is right, without an override to the OnSizeRequest method measure passes will fail and it will get a zero size. We dont layout things with zero sizes.