2015-06-12 65 views
0

在WP(Windows Runtime App)上,如果我们将应用程序设置为在Light主题上运行,在执行转换时,我们仍然可以看到黑色背景。Windows Phone 8.1黑色背景灯主题页面

有什么办法可以避免这种情况吗?

例如,在下面的动画中,您可以看到该页面动画,但在结束之前仍然有黑色背景。我想给设置为白色不知怎么的,但我不知道如何...

Image from James Croft blog post

(图片来自http://jamescroft.co.uk/blog/windows-phone/utilizing-page-transition-animations-in-windows-phone-8-1-apps/#comment-907)。

回答

1

想了一下哪些项目可以成为页面的父项之后,我将注意力转向了Frame。

这可以通过设置帧的BackgroundColor属性,在创建时,在OnLaunched方法(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方法来解决,因为这会在某些情况下,如其他应用推出URI到您的应用程序或柯塔娜发布会推出应用程序等。