Bug 60879 - Scaling broken between phone and desktop
Summary: Scaling broken between phone and desktop
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.5.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-11-27 21:49 UTC by Paul Johnson
Modified: 2018-02-15 17:37 UTC (History)
3 users (show)

Tags: scaling, desktop, phone, ac
Is this bug a regression?: ---
Last known good build:

app running on WinPhone UWP simulator (71.43 KB, image/png)
2017-11-27 21:49 UTC, Paul Johnson
desktop version (23.71 KB, image/png)
2017-11-27 21:50 UTC, Paul Johnson
desktop (additional background colours) (30.32 KB, image/png)
2017-11-27 21:50 UTC, Paul Johnson
Sign up screen (20.19 KB, application/octet-stream)
2017-11-27 21:54 UTC, Paul Johnson
base page (1.37 KB, application/octet-stream)
2017-11-27 21:55 UTC, Paul Johnson

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 Paul Johnson 2017-11-27 21:49:46 UTC
Created attachment 25836 [details]
app running on WinPhone UWP simulator

I have the following in my Main.xaml.cs to set up the screen size which is fed back into the forms singleton

        public MainPage()

            if (DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone)
                ApplicationView.GetForCurrentView().SetPreferredMinSize(new Windows.Foundation.Size(600, 600));
                ApplicationView.PreferredLaunchViewSize = new Windows.Foundation.Size(600, 600);
                ApplicationView.GetForCurrentView().TryResizeView(new Windows.Foundation.Size(600, 600));
                    var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
                    PrimordialRadio.App.ScreenSize = new Size(bounds.Width, bounds.Height);
                this.SizeChanged += FormName_SizeChanged;
                var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
                PrimordialRadio.App.ScreenSize = new Size(bounds.Width, bounds.Height);

            LoadApplication(new PrimordialRadio.App());

This works fine and sets App.ScreenSize to 600x600 on desktop or whatever the size is for the phone.

(App.ScreenSize is set as

public static Size ScreenSize {get; set;}

within the forms Singleton)

The app starts and the UI shows (see the screenshots for the difference).

The code scales by setting sizes like this

var btnClick = new Button {WidthRequest = App.ScreenSize.Width * .8, ...};

this results in the button being 4/5th the size of the screen. Works fine on all mobile platforms, but on the desktop.

It seems the desktop adds additional padding (see the proof.png image for this)

The signup.cs file is attached to this bug.

If I remove the code from mainpage.xaml.cs to set the screen size and just set the size within the singleton, I get the same results on desktop as if the code was there.

Using forms, stable release on VS2017 (15.4, community)
Comment 1 Paul Johnson 2017-11-27 21:50:15 UTC
Created attachment 25837 [details]
desktop version
Comment 2 Paul Johnson 2017-11-27 21:50:54 UTC
Created attachment 25838 [details]
desktop (additional background colours)
Comment 3 Paul Johnson 2017-11-27 21:54:01 UTC
Created attachment 25839 [details]
Sign up screen
Comment 4 Paul Johnson 2017-11-27 21:55:43 UTC
Created attachment 25840 [details]
base page

All pages inherit this page
Comment 5 Paul DiPietro [MSFT] 2017-12-10 22:47:17 UTC
Can you please upload a more complete reproduction, and verify your minimum/target versions on the UWP project?
Comment 6 Paul Johnson 2017-12-11 00:29:59 UTC

Complete solution. I've omitted the packages directory, so you'll need to restore theses to rebuild. Running the UWP project demonstrates the issue.
Comment 7 Paul DiPietro [MSFT] 2018-01-02 18:07:35 UTC
Thanks for the reproduction which does display a difference. I will set this as confirmed until further investigation can be made.
Comment 8 Samantha Houts [MSFT] 2018-02-15 17:37:17 UTC
Migrated to https://github.com/xamarin/Xamarin.Forms/issues/1893. Please follow that issue for updates. Thanks!