Should I navigate to a relative URI, or navigate to a new instance of a page in WPF?

泪湿孤枕 提交于 2020-01-06 06:26:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/562054/should-i-navigate-to-a-relative-uri-or-navigate-to-a-new-instance-of-a-page-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!