在WP(我的情况下是Windows运行时应用程序)上,如果我们将应用程序设置为在Light主题上运行,则在执行转换时,我们仍然可以看到黑色背景。
有什么办法可以避免吗?
例如,在下面的动画中,您可以看到页面动画但在结束之前仍有黑色背景。我想以某种方式将其设置为白色,但我不确定如何......
(来自 http://jamescroft.co.uk/blog/windows-phone/utilizing-page-transition-animations-in-windows-phone-8-1-apps/#comment-907的图片)。
答案 0 :(得分:1)
在思考了什么项目可能是Page的父级之后,我将注意力转向了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
}
属性来解决> 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
}
方法,因为这将在某些情况下启动,例如其他应用程序启动您的应用程序的URI或Cortana启动应用程序等。