Template10
Template10 copied to clipboard
No way to create extended spalsh screen?
In old T10 version there was a way to create extended splash screen in app constructor SplashFactory = (e) => new Views.Splash(e); There is solution to override OnLaunched method in standard UWP App. Unfortunate this method is sealed in Template 10. I did not find any description ow web. Please will you point me out where is some docs describing my problem. Thanks in advance.
I believe the smartest thing you can do is to wait to set the Window.Content. That being said, extended splash screen hasn't been on my radar. Thanks for the tip. I will look into building a sample here in a bit. If there is something fundamentally missing in this updated Template10, I'll fix it.
This works flawlessly.
public override async Task OnStartAsync(IStartArgs args)
{
if (args.StartKind == StartKinds.Launch)
{
ShowExtendedSplashScreen();
PreloadData();
await NavigateToStart();
}
else { Debugger.Break(); }
void ShowExtendedSplashScreen()
{
if (args.Arguments is IActivatedEventArgs act)
{
Window.Current.Content = new ExtendedSplash(act.SplashScreen);
}
}
void PreloadData()
{
// TODO
}
async Task NavigateToStart()
{
var navigation = Container.Resolve<Services.NavigationService>();
Window.Current.Content = new ShellPage(navigation.Service.GetXamlFrame());
await navigation.Service.NavigateAsync(nameof(MainPage));
}
}
With this ExSplash logic.
public ExtendedSplash(Windows.ApplicationModel.Activation.SplashScreen splashScreen)
{
InitializeComponent();
Window.Current.SizeChanged += (s, e) => Resize(splashScreen);
SplashImage.ImageOpened += (s, e) => Window.Current.Activate();
Resize(splashScreen);
}
private void Resize(SplashScreen splashScreen)
{
SplashImage.Height = splashScreen.ImageLocation.Height;
SplashImage.Width = splashScreen.ImageLocation.Width;
SplashContainer.SetValue(Canvas.TopProperty, splashScreen.ImageLocation.Top);
SplashContainer.SetValue(Canvas.LeftProperty, splashScreen.ImageLocation.Left);
}
I'll keep it on the backlog to remove Window.Current.Activate()
from the bootstrapper, but I've been testing it locally and this works like a charm. Let me know your experience.
Thank you for hint.