简体   繁体   中英

Windows Phone 8.1 Light theme page with black background

On WP (Windows Runtime App in my case), if we set the app to be running on Light theme, while the transition is performed, we can still see a black background.

Is there any way to avoid that?

For example, in the animation below, you can see that the page animates but before it ends there is a black background still. I'd like to set that to white somehow, but I am not sure how...

图片来自James Croft博客文章

(Image from http://jamescroft.co.uk/blog/windows-phone/utilizing-page-transition-animations-in-windows-phone-8-1-apps/#comment-907 ).

After thinking a little bit on what item could be parent of Page, I turned my attention towards Frame.

This could be solved by setting the BackgroundColor property of the Frame, when it is created, in the OnLaunched method ( App.xaml.cs):

 protected override async void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame { CacheSize = 1, Background = new SolidColorBrush(Colors.White) }; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } ... //rest of OnLaunched method } 

Also you have to make sure to set the background of the Frame as well in the OnActivated method, since this will be launched in some cases where eg other apps launch URI to your app or Cortana launches the app, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM