扩展的飞溅屏幕 - 不同于指导的样本 [英] Extended Splash Screen - Sample Different than Guidance

查看:61
本文介绍了扩展的飞溅屏幕 - 不同于指导的样本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

msdn上的当前指南  扩展启动画面 建议您将用户控件设置为Window.Current.Content。

The current guide on msdn on extending the splash screen suggests that you place a user control as the Window.Current.Content.

然而,  示例应用 它链接到但具有不同的实现。  它建议您创建一个页面并导航到它,并在页面背景中加载
流程。

However, the sample app that it links to however has a different implementation.  It suggests that you create a Page and navigate to it, and have the loading process work in the background of the page.

我遇到了与Matt类似的问题  此处  和  这里
主要是关于页面闪烁并导航到空白页面。

I have experienced similar problems to Matt here and here, mostly about the page flicker and navigating to a blank page.

看看指南如何说明Matt,我自己和示例应用程序的不同方式,我想知道什么是"最正确的" '方法是。  自8400发布以来都进行了修订,所以我不认为它们已经过时了。

Seeing how the guide states a different way to how Matt, myself, and the sample app does it, I would like to know what the 'most correct' approach is.  Both have been revised since the 8400 release, so I don't believe either is outdated.

谢谢,

Jason Grimme

Jason Grimme

推荐答案

Jason,

Jason,

我创建了一个用户控件,这样你就可以避免回头的问题 这是我的代码:

I have created a user control, this way you avoid the problems of going back.  Here's my code:

SplashScreen splashScreen = args.SplashScreen;eSplash = new ExtendedSplash(splashScreen, false);splashScreen.Dismissed += eSplash.dismissedEventHandler;Window.Current.Content = eSplash;Window.Current.Activate();




public sealed partial class ExtendedSplash : UserControl{    private Rect splashImageCoordinates; // Rect to store splash screen image coordinates.    private SplashScreen splash; // Variable to hold the splash screen object.    private bool dismissed = false; // Variable to track splash screen dismissal status.    private readonly EventHandler _loaded;            /// <summary>    /// Constructor with splash screen information    /// </summary>    /// <param name="splashImageCoordinates">coordinates of the splash screen image</param>    /// <param name="dismissed">boolean value indicating whether the splash screen has been dismissed</param>    public ExtendedSplash(SplashScreen splashScreen, bool dismissed, EventHandler LoadedHandler = null)    {        InitializeComponent();                    splash = splashScreen;        this.dismissed = dismissed;        _loaded = LoadedHandler;                    SetPositions();        Window.Current.SizeChanged += ExtendedSplash_OnResize;        Loaded += ExtendedSplash_Loaded;    }    void ExtendedSplash_Loaded(object sender, RoutedEventArgs e)    {        // now load our data                }    private void SetPositions()    {        this.splashImageCoordinates = splash.ImageLocation;        Debug.WriteLine(splashImageCoordinates.ToString());        // Position the extended splash screen image in the same location as the splash screen image.        extendedSplashImage.SetValue(Canvas.LeftProperty, this.splashImageCoordinates.X);        extendedSplashImage.SetValue(Canvas.TopProperty, this.splashImageCoordinates.Y);        extendedSplashImage.Height = this.splashImageCoordinates.Height;        extendedSplashImage.Width = this.splashImageCoordinates.Width;        LoadingIndicator.Measure(new Size(double.MaxValue, double.MaxValue));        LoadingIndicator.SetValue(Canvas.LeftProperty, this.splashImageCoordinates.X + (splashImageCoordinates.Width-LoadingIndicator.ActualWidth)/2);        LoadingIndicator.SetValue(Canvas.TopProperty, this.splashImageCoordinates.Y + 380);    }    void ExtendedSplash_OnResize(Object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)    {        // Safely update the splash screen image coordinates        if (this.splash != null)        {            SetPositions();                        }    }    /// <summary>    /// Event handler for dismissed event to know when the Splash screen is dismissed    /// </summary>    /// <param name="sender">SplashScreen</param>    internal void dismissedEventHandler(Windows.ApplicationModel.Activation.SplashScreen sender, object e)    {        this.dismissed = true;    }}

然后,一旦我的所有数据都被加载,我用新的rootframe替换窗口内容并导航正确的页面等。 似乎对我来说效果很好。

Then once all my data is loaded, I replace the window content with my new rootframe and navigate the correct page etc.  Seems to work pretty well for me.

HTH。

... Stefan

...Stefan


这篇关于扩展的飞溅屏幕 - 不同于指导的样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆