1

I'm working on a WinRT App that has multiple pages using the Basic Page template. Each page has 1366*768 resolution background images and when navigating from a page to another there's an undesired and annoying blinking effect. Is there any trick I could get rid of it? I've had some tries to look upon the images' properties but no luck so far. Can this be achieved?

Any help is greatly appreciated, thank you.

4

2 回答 2

3

我通过在主框架的背景上设置图像来删除它。

在您的 app.cs 文件中添加以下代码:-

    protected override void OnLaunched(LaunchActivatedEventArgs args)
    {
        Frame rootFrame = Window.Current.Content as Frame;
        ImageBrush brush = new ImageBrush();
        BitmapImage image = new BitmapImage(new Uri("..."));
        brush.ImageSource = image;
        rootFrame.Background = brush;

这样可以防止闪烁。

于 2012-12-21T12:40:35.170 回答
1

罗斯的回答很简单,接近我的想法。我可能会使用两个图像控件,并在它们之间交替设置图片+在新图像加载后运行溶解过渡动画。

我认为 WinRT XAML 的工作方式是当您导航到在可视树中包含图像的新页面时 - 它可能会延迟打开新页面几分之一秒以等待图像加载,但仅适用于短时间。我认为这就是发生的情况,因为我看到打开了新页面并在我的笔记本电脑上加载了图像,但它似乎超时了,因为在 Surface 上 - 它首先显示没有图像并且它们只是稍后才弹出。

如果您想试一试 WinRT XAML Toolkit - 它还有一些其他机制可能对您有所帮助。与 AlternativePage 一起使用的 AlternativeFrame 是 Frame/Page 的交换,具有几乎相同的 API,但 Navigate 方法是异步的,它允许您等待下一页加载其图像(设置 ShouldWaitForImagesToLoad="True"在框架或页面上)或其他内容,然后再打开它,并且支持页面转换。它还有一个 Preload() 方法,允许您在调用 Navigate 之前在内存中预加载下一页,因此它可以在用户的​​操作调用 Navigation 调用时显示出来(假设您没有太多选择导航到您所在的位置)。

您可以从那里使用的另一个工具是 ImageExtensions.FadeInOnLoaded 属性,该属性使您的图像在加载时平滑淡入,而不仅仅是弹出。

于 2012-12-21T17:16:52.450 回答