Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splashscreen Rect coordinates returning Screen dimensions on Win 10 Mobile

I am trying to create an extended SplashScreen on my UWP app for which the SplashScreen image coordinates are needed. I am using the following code in App.xaml.cs:

 protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            if (e.SplashScreen != null)
                var SplashLocation = e.SplashScreen.ImageLocation;
            //Rest of initialization...
        }

However, if I inspect SplashLocation which is a Rect, SplashLocation.Height and SplashLocation.Width return 1280 and 768 which is the dimension of my phone's screen. All other properties are 0.

Is this a known bug in Win 10 Mobile [build 10536]? It works fine on desktop Windows 10.

like image 756
Saurabh3321 Avatar asked Nov 19 '25 09:11

Saurabh3321


1 Answers

Actually the issue is that the code given on the MSDN docs is wrong. Have a look at their samples on Github instead. You can find it here: Splash Screen Sample

Notice the differences between the MSDN docs and the sample:

  1. ExtendedSplash DOES NOT extend page
  2. They use a ScaleFactor for phone
  3. The root element of the XAML is Grid and not page.

I followed their sample (after hours of wondering) and it all worked well. I hope they update their docs to reflect the correct thing.

like image 194
Saurabh Avatar answered Nov 21 '25 23:11

Saurabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!