admin管理员组文章数量:1389903
I am using C# Maui with the .NET 9.0 SDK.
Using routes registered using Routing.RegisterRoute
and navigating between views using Shell.Current.GoToAsync
seems to result in some odd shell states.
For example, after registering the following views:
Routing.RegisterRoute("login", typeof(LoginPage));
Routing.RegisterRoute("profile", typeof(ProfilePage));
Routing.RegisterRoute("history", typeof(HistoryPage));
If a user navigates from login to profile to history and back to profile, eventually the app's shell state resembles the following:
////login/profile/history/profile
When the app reaches this state, attempting to navigate from profile to history a second time produces the error in the method SearchForGlobalRoutes
of the ShellUriHandler
object.:
Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
Similarly, in the same scenario attempting to navigate backwards using the ..
notation results in an error that the route could not be discovered.
Has anyone else had this sort of experience? Is there something I am missing in either the registration or navigation of my routes?
Edit
I should mention that navigating away from the startup view using an absolute path such as the following seems to result in the app hanging / becoming non-responsive:
Shell.Current.GoToAsync("//profile")
Navigating using either of the following does not suspend the app, but results in the odd state shown above:
Shell.Current.GoToAsync("profile")
Shell.Current.GoToAsync("/profile")
Edit
At the time of posting, all routes were registered in the CreateMauiApp
method of the MauiProgram class.
Since posting, I have also tried registering routes in the constructor of the AppShell class, but have had no significant change in behavior.
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
RegisterRoutes();
}
private void RegisterRoutes() {
Routing.RegisterRoute("profile", typeof(ProfilePage));
Routing.RegisterRoute("history", typeof(CallHistoryPage));
Routing.RegisterRoute("settings", typeof(SettingsPage));
}
}
本文标签: cNavigating back and forth between views creates odd states in NET MauiStack Overflow
版权声明:本文标题:c# - Navigating back and forth between views creates odd states in .NET Maui - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744581318a2613938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论