I am using template 10 and want my splash screen to look like this:
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:
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.
Although it uses Canvas
in the official document to show the content of the extended splash screen, there is no need to code exactly same as the document, the code in the document is just for a example. Even you don't need to create a new blank page for extended splash screen, you can also create a UserControl
to do this.
For some information about using Extended Splash Screen in Template 10
, you may refer to Template10: a new template to create Universal Windows apps – The basics.
So here is my example, I created a UserControl
named ExtendedSplash
:
<Grid Background="#00b2f0">
<mycontrols:RoundProgressControl x:Name="ProgressControl" HorizontalAlignment="Center" VerticalAlignment="Center"
Size="300" LineWidth="8" Color="Orange" />
</Grid>
The code behind is very simple just handling the TimeTikcer of the circular progressbar:
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;
}
}
}
To use this ExtendedSplash
, you can in the App.xaml.cs file code like this:
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));
}
}
The reason why using SplashFactory
is explained in the blog I provided above. And you can find my sample here.
Update:
First of all, this error code is not my code, this is your provided circular progress bar. And this is a COM-based APIs error code. The error message is quite clear: The message filter indicated that the application is busy. As you said, "while it is in hanged state", this error occurred.
A simple way to handle this exception, you can add a "try catch" to this code like this:
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());
}
}