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

本文关键字:quot null OnStar is Content Window Current as Frame | 更新日期: 2023-09-27 18:32:44

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

Frame rootFrame = Window.Current.Content as Frame;

显然有些事情发生了变化,因为当我在 1.0.8 上时,这工作正常,现在rootFrame对象为 null。 我检查BackStack的目的是插入MainPage如果应用程序是从ToastNotification启动到特定页面的。

我希望有人能帮助我。

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

看看 NavigationService.Frame:

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