Bug 53032 - StackLayout incorrectly calculating label size within CarouselPage
Summary: StackLayout incorrectly calculating label size within CarouselPage
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-03-03 22:40 UTC by James
Modified: 2017-07-12 22:51 UTC (History)
6 users (show)

Tags: bug, android, stacklayout, label, carouselpage ac
Is this bug a regression?: ---
Last known good build:

Sample Project Exhibiting the issue (77.80 KB, application/x-zip-compressed)
2017-03-03 22:40 UTC, James
repro project (52.16 KB, application/x-zip-compressed)
2017-03-24 16:09 UTC, Jimmy [MSFT]

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 for Bug 53032 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description James 2017-03-03 22:40:53 UTC
Created attachment 20128 [details]
Sample Project Exhibiting the issue

It appears that Labels in a StackLayout have their width incorrectly calculated for Pages in a CarouselPage not currently loaded on screen. See attached app for reproduction

1. Load app and in the master view of the Master Detail select Carousel
1a. Observe the Text in its Horizontal alignment, labels are end, center end
2. Swipe right to the green page
2a. Observe label is centered here
3. Select Contacts from the Master View
4. Select Carousel
4a. Notice here the "green" Label is still centered
5. Swipe left to the Red screen

Expected, Text alignment is preserved
Actual, text is aligned at Start

What I think is happening is when the CarouselPage is loaded, the Labels calculated size fills the entire horizontal span, and thus the text is centered. When you load a different page, navigate away from the CarouselPage, navigate back and then return to the original loaded CarouselPage, the Labels width is misscalculated to only be the length of the text, and the Label control itself instead of the fill. So while HorizontalTextAlignment is preserved, the acutal size of the Label changes.

As a note, commented in the code is the same setup using a Grid instead of a StackLayout, and this issue is not exhibited.

Found using Xamarin.Forms
Comment 1 Jimmy [MSFT] 2017-03-06 18:49:36 UTC
Thank you for reporting this! Let me run the attached project to try reproducing this so I can confirm this issue. I will update the report with my results.
Comment 2 Jimmy [MSFT] 2017-03-24 16:09:57 UTC
Created attachment 20813 [details]
repro project

I was able to reproduce this issue with the project provided. I'm attaching a minimized version with new repro steps and confirming this issue so the team can investigate further.

### Steps to Reproduce
1. Run the attached project
2. Swipe to the green page
3. Press "Next Page"
4. Press "Go Back"
5. Swipe back to the red page

### Expected Results
The bottom Label will still be End aligned

### Actual Results
The Label appears to be Start aligned

### Regression Test
2.3.4-pre5      BAD       BAD