Bug 42684 - Layout manager not handling Restore from Maximised on UWP
Summary: Layout manager not handling Restore from Maximised on UWP
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-20 11:56 UTC by John Hardman
Modified: 2016-08-11 18:35 UTC (History)
3 users (show)

Tags: UWP Maximise Restore Layout Label ac
Is this bug a regression?: ---
Last known good build:


Attachments
First image, before Maximise (69.56 KB, image/png)
2016-07-20 11:56 UTC, John Hardman
Details
Second image, after maximise (82.28 KB, image/png)
2016-07-20 11:57 UTC, John Hardman
Details
Third image, after Restore (53.98 KB, image/png)
2016-07-20 11:57 UTC, John Hardman
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 for Bug 42684 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:
Status:
CONFIRMED

Description John Hardman 2016-07-20 11:56:22 UTC
Created attachment 16729 [details]
First image, before Maximise

When running a UWP app on a desktop device, maximising the window in which the app is running, then restoring it again, results in the page not being laid out correctly.

If the user re-sized the window by dragging the corner until near full-screen, then re-sizes by dragging the corner back to the original size, the page is laid out correctly. It therefore would appear that the layout manager is not handling Restore correctly.

In the attached images, the first shows before doing Maximise, the second is after Maximise, the third is after Restore. I have circled on the third image the Label that is not being laid out correctly (as mentioned previously, re-sizing lays it out correctly, Restore does not).
Comment 1 John Hardman 2016-07-20 11:57:01 UTC
Created attachment 16730 [details]
Second image, after maximise
Comment 2 John Hardman 2016-07-20 11:57:35 UTC
Created attachment 16731 [details]
Third image, after Restore
Comment 3 John Hardman 2016-07-20 12:09:48 UTC
Note that on a mobile device, a similar issue occurs when switching from landscape orientation to portrait orientation.
Comment 4 Paul DiPietro [MSFT] 2016-08-09 16:35:47 UTC
What's your layout look like for that page? Seems like a basic label on a content page doesn't act funny as I check it on my end, but I imagine that text/label in the screenshots is inside something? Got a repro by chance?
Comment 5 John Hardman 2016-08-09 20:57:18 UTC
Will try to find time to create a repro sample.

The bit of the page where the issue shows up is:

a ListView
that is a child of a StackLayout
that is a child of a StackLayout
that is a child of a RelativeLayout
that is a child of a StackLayout
that is a child of a StackLayout
that is the content of a ContentPage

The ListView shows ViewCells that are composed of 

a StackLayout
that contains a StackLayout and a BoxView,
where that StackLayout contains two Labels, both of which have LineBreakMode = LineBreakMode.WordWrap
Comment 6 John Hardman 2016-08-10 21:36:38 UTC
The following ContentPage code demonstrates the problem. Just create an instance and push it onto the NavigationStack and await (I've included a static helper that does this). Reduce the width of the page as much as you can, maximise it, then restore it. The text that was previously word-wrapped no longer is. It seems that restore is not being handled correctly.


using System.Collections.ObjectModel;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace ViewsUsingXamarinForms
{
    public class DummyViewModel
    {
    }

    public class Bug42684Page : ContentPage
    {
        public static Task ShowPageAsync(ContentPage parentPage)
        {
            Bug42684Page pageView = new Bug42684Page();
            return parentPage.Navigation.PushAsync(pageView);
        }

        public Bug42684Page()
        {
            ObservableCollection<DummyViewModel> _viewModel
                = new ObservableCollection<DummyViewModel>
                {
                    new DummyViewModel(),
                    new DummyViewModel(),
                    new DummyViewModel()
                };

            ListView lstView = new ListView
            {
                BackgroundColor = Color.White,
                SeparatorColor = Color.Silver,
                HorizontalOptions = LayoutOptions.Fill,
                ItemsSource = _viewModel,
                ItemTemplate = new DataTemplate(typeof(CustomViewCell))
            };

            Content = lstView;
            Title = "Bug 42684";
        }

        public class CustomViewCell : ViewCell
        {
            public CustomViewCell()
            {
                Label labelOne = new Label
                {
                    BackgroundColor = Color.White,
                    HorizontalOptions = LayoutOptions.Fill,
                    TextColor = Color.Black,
                    LineBreakMode = LineBreakMode.WordWrap,
                    Text = "This is a fairly long string that we expect to word wrap when our page is of a typical width. We even add a second sentence to make sure."
                };
                Label labelTwo = new Label
                {
                    BackgroundColor = Color.White,
                    HorizontalOptions = LayoutOptions.Fill,
                    TextColor = Color.Black,
                    LineBreakMode = LineBreakMode.WordWrap,
                    Text = "This is a fairly long string that we expect to word wrap when our page is of a typical width. We even add a second sentence to make sure."
                };
                StackLayout sl = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Children =
                    {
                        labelOne,
                        labelTwo
                    }
                };

                this.View = sl;
            }

        } // constructor
    } // class
} // namespace

// eof
Comment 7 Paul DiPietro [MSFT] 2016-08-11 16:22:49 UTC
Thanks for that code since I can see what you're referring to, now.
Comment 8 John Hardman 2016-08-11 18:35:39 UTC
Just discovered that the same symptom can result from rapidly re-sizing a window (e.g. have it near full screen size, then drag the right-hand edge to the left as fast as possible). A slow re-size is fine, a quick one can result in the same formatting issue seen with using Restore.