"Window.Current.Content as Frame" 为空 - OnStartAsync

"Window.Current.Content as Frame" is null - OnStartAsync

我刚刚将Template10从1.0.8版本升级到1.1.2,现在我遇到了以下问题。在 OnStartAsync() 中,我尝试获取当前帧并检查其 BackStack

Frame rootFrame = Window.Current.Content as Frame;

显然发生了一些变化,因为当我使用 1.0.8 时它运行良好,现在 rootFrame 对象为空。 如果应用程序是从 ToastNotification 启动到特定页面,我检查 BackStack 的目的是插入 MainPage

我希望有人能帮助我。

看看NavigationService.Frame:

public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
    var frame = NavigationService.Frame;
    NavigationService.Navigate(typeof(Views.MainPage));
    return Task.CompletedTask;
}