我有一个非常简单的导航堆栈,由一个根页面和一个位于其顶部的模型页面组成。我的根页面通过成为向 Shell 注册的第一个页面被设置为根。
public AppShell()
{
InitializeComponent();
// opening view
Regester<LoginPage>();
Regester<SignUpPage>();
...
}
private void Regester<T>()
{
System.Diagnostics.Debug.WriteLine($"Regestering with shell : {typeof(T).Name} - {typeof(T)}");
Items.Add(new ShellContent { Route = typeof(T).Name, ContentTemplate = new DataTemplate(typeof(T)) });
Routing.RegisterRoute(typeof(T).Name, typeof(T));
}
}
然后我使用相对路由导航到模型注册页面
Shell.Current.GoToAsync("SignUpPage");
或者我将使用绝对路由
Shell.Current.GoToAsync("///LogInPage/SignUpPage");
然后我将尝试使用
Shell.Current.GoToAsync("..");
但我得到了这个例外
Global routes currently cannot be the only page on the stack, so absolute routing to global routes is not supported. For now, just navigate to: LoginPage/
在异常时 CurrentState.Location 属性是这个
Location = {///LoginPage/SignUpPage}
我不明白为什么会这样。如果我进一步深入堆栈并执行诸如尝试从详细信息页面导航回来的操作,也会发生这种情况。我需要做什么才能正确使用 GoToAsync("..")?