Bug 31107 - BackgroundColor being ignored when number of entries in StackLayout reaches a threshold
Summary: BackgroundColor being ignored when number of entries in StackLayout reaches a...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-15 10:55 UTC by John Hardman
Modified: 2016-08-09 13:49 UTC (History)
6 users (show)

Tags: WinPhone StackLayout BackgroundColor Spacing
Is this bug a regression?: ---
Last known good build:

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 FIXED

Description John Hardman 2015-06-15 10:55:19 UTC
I am hitting a strange problem on WinPhone, where the BackgroundColor of a StackLayout is being ignored when the number of entries in the StackLayout goes over a certain number (when my app hits 57 children of the StackLayout, but remembering that some of those children have children of their own). The StackLayout is created as follows (I have hard-coded the color and spacing to assist in debugging. On iOS this works fine, but on WinPhone the moment the number of entries hits that threshold, the BackgroundColor on WinPhone switches to Black (presumably Color.Default?).

I am using 1.4.3.6358-pre2 .


                menuStackLayout = new StackLayout
                {
                    BackgroundColor = Color.Maroon,
                    ClassId = "MyApp_ClassId_StackLayout",
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    IsEnabled = true,
                    IsVisible = true,
                    Orientation = StackOrientation.Vertical,
                    Padding = 0,
                    Spacing = 50,
                    StyleId = kmr.StyleId,
                    VerticalOptions = LayoutOptions.FillAndExpand
                };
Comment 1 Abhishek 2015-07-03 06:09:30 UTC
I have tried this issue and unable to reproduce the reported behavior at my end.

Steps to Reproduce:
1. Create an PCL form application.
2. Copy the above code and paste on App.cs 
3. Run the application on Device/Win-Emulator.

screencast: http://www.screencast.com/t/qcxD6nQRi
IDE log: https://gist.github.com/Parmendrak/37d3d8cef0e4beac1976

Could you please provide me test sample along with the bug so that I can reproduce this issue at my end.Also Provide the IDE log.

IDE Log via :Help->Xamarin->Zip Xamarin Logs.

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
 
Xamarin   3.11.666.0 (ebae43a)
Xamarin.Android   5.1.4.16 (5f55a9ef61c11b6ce0890bc91e4c71b1b92be214)
Xamarin.Forms Intellisense   1.0
Xamarin.iOS   8.10.2.0 (67b390d0d1bd741582cf7b7fd3ffea08583a3f83)
Xamarin.iOS Unified Migration   1.0
Xamarin.TestCloud.Integration   1.0
Comment 2 John Hardman 2016-02-05 16:05:46 UTC
I don't build my app for WinPhone 8.0 any more, but just updated dependencies etc to allow me to re-test this using XF 2.0 on WinPhone 8.0. The problem still occurs (in fact it happens even more often than it used to). Populate a ContentPage as follows. With the loop counter set to 10, the background color of Fuchsia is seen. Increase that counter to 300 (or even 30 as I discovered just now) and the background color is black, even though the code still says to use Fuchsia.


            Color[] colors =
            {
                Color.Aqua,
                Color.Blue,
                Color.Gray,
                Color.Green,
                Color.Lime,
                Color.Maroon,
                Color.Navy,
                Color.Olive
            };
            
            StackLayout vsl = new StackLayout
            {
                BackgroundColor = Color.Pink,
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                ClassId = "MyApp_ClassId_StackLayout",
                IsEnabled = true,
                IsVisible = true,
                Padding = 0,
                Spacing = 50,
                StyleId = "StyleId"
            };

            for (int i = 0; i < 10; ++i) // THIS IS THE COUNTER TO CHANGE
            {
                vsl.Children.Add(
                    new Label
                    {
                        Text = String.Format("  {0}", i),
                        BackgroundColor = colors[i%8],
                        TextColor = Color.Silver,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                    });    
            }

            ScrollView sl = new ScrollView
            {
                BackgroundColor = Color.Fuchsia,
                Orientation = ScrollOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                Content = vsl
            };

            this.Content = sl;
Comment 3 John Hardman 2016-02-05 16:08:02 UTC
Sorry, should have said Pink, not Fuchsia.
Comment 4 Rui Marinho 2016-08-09 13:49:52 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