MAUI页面导航-await Shell.Current.GoToAsync()与Navigation.PushAsync();

示例:

Shell.Current.GoToAsync("..");  // 导航到前一页
Shell.Current.GoToAsync(nameof(NotePage));  // 导航到Note页
Shell.Current.GoToAsync($"{nameof(NotePage)}?{nameof(NotePage.ItemId)}={Value}");  // 导航到Note页并给Note页的ItemId变量赋值,需要标识NotePage类,如下两行
// [QueryProperty(nameof(ItemId), nameof(ItemId))]
// public partial class NotePage : ContentPage

注:需要在AppShell.cs的public AppShell()方法中注册此页面Routing.RegisterRoute(nameof(NotePage), typeof(NotePage));  // 注册页面

示例:

await Navigation.PushAsync(new HelloXamlPage());

其他:

Routing.RegisterRoute(nameof(TodoItemPage), typeof(TodoItemPage));

 

posted @   ꧁执笔小白꧂  阅读(978)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示