Win10的UWP之标题栏的返回键(一)
来源:互联网 发布:亚马逊的大数据行动 编辑:程序博客网 时间:2024/05/20 20:22
关于返回键,放在标题栏是目前较为完美的一种方案。继前一篇的Hello World,博主进行一些修改实现该方法。
- - - - - - - - - - - - - - - - - - - - - - - 我是万恶的分割线- - - - - - - - - - - - - - - - - - -
在OnLaunched的方法中加
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += BackRequested;
紧接着在加一段代码
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : Windows.UI.Core.AppViewBackButtonVisibility.Collapsed; rootFrame.Navigated += OnNavigated;
我们在继续把代码写完用两个方法来适配前面写的两段代码
private void OnNavigated(object sender, NavigationEventArgs e) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = ((Frame)sender).CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }
private void BackRequested(object sender, BackRequestedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) return; if (rootFrame.CanGoBack && e.Handled == false) { e.Handled = true; rootFrame.GoBack(); } }
为了能够看见效果,我们另外添加了一个页面
然后主界面的代码如下
基本的都做完了我们来看一下效果怎么样
3 0
- Win10的UWP之标题栏的返回键(一)
- Win10的UWP之标题栏的返回键(二)
- Win10的UWP之进度条
- Win10的UWP开发之Hello World
- Win10之UWP的数据存储
- win10 UWP 标题栏后退
- Win10开发之UWP控件的隐藏空间
- win10 uwp 获取指定的文件 AQS
- UWP——HttpClient模拟浏览器的GET、POST请求之Win10 Mobile测试
- Win10/UWP开发:让你的App使用上扫描仪
- Win10 UWP 开发系列:支持异步的SQLite
- win10 uwp 上传Nuget 让别人用我们的库
- win10 uwp 使用动画修改 Grid column 的宽度
- win10 uwp 获得Slider拖动结束的值
- 【UWP开发】如何获取win10和xbox one的用户信息
- 【Win10】UAP/UWP/通用 开发之 SplitView
- 看了下微软更新的Win10系统,特地开了个UWP目录,与大家交流UWP开发
- android带返回按钮的自定义标题栏
- Dubbo相关问题
- Android横竖屏切换总结
- 合并挖矿机制
- BigInteger类(大数运算)
- android中Intent的使用
- Win10的UWP之标题栏的返回键(一)
- HDU 1598 find the most comfortable road
- 【Jenkins】包含dubbo服务的war包自动部署tomcat
- jzoj2931 书架
- android中判断关于文本展示是否出现省略号的判断
- Qt之QSequentialAnimationGroup
- mysql添加外键
- There was an internal API error.
- 生命周期方法