Bug 36648 - Landscape and portrait
Summary: Landscape and portrait
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-12-05 15:24 UTC by Alessandro
Modified: 2016-02-08 16:34 UTC (History)
5 users (show)

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

Test case (219.13 KB, application/zip)
2015-12-08 16:38 UTC, Alessandro

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 Alessandro 2015-12-05 15:24:05 UTC
I try to raise an event when device is moved from portrait to landscape and from landscape to portrait.

I have a master detail page with PageMaster and PageDetail.

If I have this code in PageDetail (the page in Detail side)

    protected override void OnSizeAllocated (double width, double height)
        base.OnSizeAllocated (width, height);

        if (width != _width || height != _height)
            _width = width;
            _height = height;
            if (width > height) // Landscape
                App.Globali.IsLandscape = true;
                App.Globali.IsLandscape = false;

every time I move device from landscape to portrait, Width and height changes.

If I have the same code in PageMaster (the page in Master side), the event is raised every time I move device from landscape to portrait and from portrait to landscape, but width and height does not change.

The same situation occurs if I have this code connected to a StackLayout

        sl.SizeChanged += (object sender, EventArgs e) => {
            if(this.Width > this.Height)
                App.Globali.IsLandscape = true;
                App.Globali.IsLandscape = false;

In StackLayout present in PageDetail I have width and height that changes if I move the device from L to P.
In StackLayout present in PageMaster I have the event raised but Width and height does not change.
Comment 1 Alessandro 2015-12-05 20:58:38 UTC
It seems that the problem is only on iOS (emulator iPhone 6s 9.1).
In Android (emulator 5.1.0 api 21 Nexus 5) seems to change Width and Height values
Comment 2 Alessandro 2015-12-08 16:38:04 UTC
Created attachment 14186 [details]
Test case

Take a look to Debug.WriteLine. In Android you see correct LANDSCAPE and PORTRAIT string.
in iOS you see an error in MASTER...
Comment 3 E.Z. Hart [MSFT] 2016-02-08 16:34:14 UTC
"width > height" is not a valid test for whether a Master Page is in landscape mode, because the Master Page doesn't necessarily cover the width of the screen.