diff --git a/src/Caliburn.Micro.Platform/Platforms/UWP/CaliburnApplication.cs b/src/Caliburn.Micro.Platform/Platforms/UWP/CaliburnApplication.cs index 42ce6445..05613471 100644 --- a/src/Caliburn.Micro.Platform/Platforms/UWP/CaliburnApplication.cs +++ b/src/Caliburn.Micro.Platform/Platforms/UWP/CaliburnApplication.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Threading; +using System.Threading.Tasks; using Windows.ApplicationModel; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -257,7 +259,7 @@ protected void DisplayRootView(object parameter = null) /// Locates the view model, locates the associate view, binds them and shows it as the root view. /// /// The view model type. - protected void DisplayRootViewFor(Type viewModelType) + protected async Task DisplayRootViewForAsync(Type viewModelType, CancellationToken cancellationToken) { Initialize(); @@ -266,21 +268,24 @@ protected void DisplayRootViewFor(Type viewModelType) ViewModelBinder.Bind(viewModel, view, null); - var activator = viewModel as IActivate; - if (activator != null) - activator.Activate(); + if (viewModel is IActivate activator) + await activator.ActivateAsync(cancellationToken); Window.Current.Content = view; Window.Current.Activate(); } + protected Task DisplayRootViewForAsync(Type viewModelType) => DisplayRootViewForAsync(viewModelType, CancellationToken.None); + /// /// Locates the view model, locates the associate view, binds them and shows it as the root view. /// /// The view model type. - protected void DisplayRootViewFor() + protected Task DisplayRootViewForAsync(CancellationToken cancellationToken) { - DisplayRootViewFor(typeof(T)); + return DisplayRootViewForAsync(typeof(T), cancellationToken); } + + protected Task DisplayRootViewForAsync() => DisplayRootViewForAsync(CancellationToken.None); } }