WP MVVM导航OnNavigatedTO [英] WP MVVM Navigation OnNavigatedTO

查看:114
本文介绍了WP MVVM导航OnNavigatedTO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在我的应用程序中实现MVVM,但遇到了一个问题,即知道用户何时导航到视图.

I am starting to implement MVVM in my application and got an issue of knowing when the user navigated to the view.

要在视图之间导航,我只能使用navigationService.Navigate(...);

To navigate between views, I can just use the navigationService.Navigate(...);

如何查看导航到该视图的时间? 我可以使用事件navigationService.Navigated吗?

How do I check when I navigated to the view? May I use the event navigationService.Navigated?

我是否可以使用页面本身提供的其他类似OnNavigatedTo的方法?

Is there no other method I can use like OnNavigatedTo that the page itself provide?

推荐答案

感谢提供的答案.在我决定创建由少数人创建的导航服务的自定义实现之前,两者在一段时间内都是有用的. 然后,我对Cimbalino工具箱做出了贡献以提出建议,并且该工具箱已在不久前推出.

Thanks for the answers provided. Both were helpful over a period of time until I decided to create a custom implementation of the navigation service that has been created by a few people. I then made a contribution to the Cimbalino toolkit to suggest this and it has been introduced a while back.

我个人认为,这可以最好地解决我的问题.看看那里的导航服务.导航事件几乎解决了我遇到的问题.

I my personal opinion, that solves my issue the best. Have a look at the navigation service in there. The Navigated event pretty much solves my issue I had.

https://github.com/Cimbalino/Cimbalino-Toolkit

基本上可以归结为这一点(在您的视图模型中):

It basically comes down to this (in your viewmodel):

_navigationService.Navigated += OnNavigated;

这篇关于WP MVVM导航OnNavigatedTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆