我应该导航到相对URI,还是导航到WPF中页面的新实例? [英] Should I navigate to a relative URI, or navigate to a new instance of a page in WPF?

查看:72
本文介绍了我应该导航到相对URI,还是导航到WPF中页面的新实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用frame.Navigate和设置frame.Source = new MyPage()之间有什么区别吗?其中之一在内存使用方面是否更有效率?使用特定方法时,框架的日志(后退,前进按钮)是否受到不同的影响?

Is there any difference between calling frame.Navigate and setting frame.Source = new MyPage()? Is one of them more efficient when it comes to memory usage, and is the frame's journal (back, forward buttons) affected differently when using a particular method?

推荐答案

是的,有区别.您导航到的内容已记录.这意味着,如果您导航到页面,则整个页面在日记中的生存时间将一直保持在导航历史记录中.从内存的角度出发,最好导航到一个Uri.请注意,WPF中的导航系统和日记功能非常复杂,并且经常与生命周期管理不一致.这里有龙.在选择使用内置导航系统之前,请尽可能多地了解此主题.

Yes, there's a difference. What you navigate to is journaled. This means that if you navigate to a Page, the entire Page is kept alive in the journal for as long as it would remain in navigation history. It's better, memory wise, to navigate to a Uri. Be aware that the navigation system and journaling in WPF is quite complex, and often at odds with lifetime management. There be dragons here. Learn as much about this subject as you can, before choosing to use the built-in navigation system.

这篇关于我应该导航到相对URI,还是导航到WPF中页面的新实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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