1

I am using template 10 and want my splash screen to look like this:

enter image description here

enter image description here

enter image description here

I have got the circular progress Bar control Here and got it around a image through Grace Feng help from this code Link

Now I want this round progress control into my splash screen so it look like like the above images but in the extended splash screen link tutorial they show it by canvas and i want to do it by Myprogress control any idea how to implement this control in extended splash screen.If i just use it in splash.xaml then my app builds and start but then it hangs.But removing this control it runs perfectly.Any help would be appreciated. Thank You.

Getting this error in Grace Feng Sample: Error

Error2

4

1 回答 1

1

但是在扩展的初始屏幕链接教程中,他们通过画布显示它,我想通过 Myprogress 控件来完成它,任何想法如何在扩展的初始屏幕中实现此控件。

虽然Canvas官方文档中使用的是显示扩展闪屏的内容,但不需要和文档完全一样的代码,文档中的代码只是一个示例。即使您不需要为扩展的初始屏幕创建新的空白页面,您也可以创建一个UserControl 来执行此操作。

有关使用的一些信息Extended Splash Screen in Template 10,您可以参考Template10:创建通用 Windows 应用程序的新模板 - 基础知识

所以这是我的例子,我创建了一个UserControl名为ExtendedSplash

<Grid Background="#00b2f0">
    <mycontrols:RoundProgressControl x:Name="ProgressControl" HorizontalAlignment="Center" VerticalAlignment="Center"
                                     Size="300" LineWidth="8" Color="Orange" />
</Grid>

后面的代码很简单,只是处理循环进度条的 TimeTikcer:

public sealed partial class ExtendedSplash : UserControl
{
    private Timer TheTimer = null;
    private object LockObject = new object();
    private double ProgressAmount = 0;
    public ExtendedSplash()
    {
        this.InitializeComponent();
        this.Loaded += (sender, e) =>
        {
            TimerCallback tcb = HandleTimerTick;
            TheTimer = new Timer(HandleTimerTick, null, 0, 30);
        };

        this.Unloaded += (sender, e) =>
        {
            lock (LockObject)
            {
                if (TheTimer != null)
                    TheTimer.Change(Timeout.Infinite, Timeout.Infinite);
                TheTimer = null;
            }
        };
    }

    public void HandleTimerTick(Object state)
    {
        lock (LockObject)
        {
            ProgressControl.SetBarLength(ProgressAmount);
            ProgressAmount += 0.006;
            if (ProgressAmount > 1.5)
                ProgressAmount = 0.0;
        }
    }
}

要使用它ExtendedSplash,您可以在 App.xaml.cs 文件中编写如下代码:

sealed partial class App : Template10.Common.BootStrapper
{
    public App()
    {
        InitializeComponent();
        SplashFactory = e => new ExtendedSplash();
    }

    public override async Task OnInitializeAsync(IActivatedEventArgs args)
    {
        await Task.CompletedTask;
    }

    public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
    {
        await Task.Delay(TimeSpan.FromSeconds(6));
        NavigationService.Navigate(typeof(Views.MainPage));
    }
}

SplashFactory我在上面提供的博客中解释了使用的原因。你可以在这里找到我的样品

更新:

首先,这个错误代码不是我的代码,这是你提供的循环进度条。这是一个基于 COM 的 API 错误代码。错误消息很清楚:消息过滤器指示应用程序正忙。正如您所说,“当它处于挂起状态时”,发生了这个错误。

处理此异常的一种简单方法是,您可以向此代码添加“try catch”,如下所示:

public void SetBarLength(double Value)
{
    try
    {
        if (DesignMode.DesignModeEnabled)
            SetBarLengthUI(Value);
        else if (CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess)
            SetBarLengthUI(Value);
        else
        {
            double LocalValue = Value;
            IAsyncAction IgnoreMe = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SetBarLengthUI(Value); });
        }
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.ToString());
    }
}
于 2016-06-27T07:32:38.133 回答