什么时候应该使用 UserControl 而不是 Page? [英] When should I use a UserControl instead of a Page?

查看:29
本文介绍了什么时候应该使用 UserControl 而不是 Page?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到许多 WPF MVVM 框架似乎避免使用 NavigationWindow 和 Page 控件,而倾向于使用嵌套的 UserControl 来编写页面.

I notice that many of the WPF MVVM frameworks seem to avoid using the NavigationWindow and Page controls in favor of composing pages using nested UserControls.

NavigationWindow 和 Page 提供了在日志中启用向后和向前导航的简单方法,并提供了在页面之间传递数据的简单方法.我见过的大多数 MVVM 框架都以各种方式重新实现了这些功能.

The NavigationWindow and Page provide easy ways to enable back and forward navigation in the journal as well as providing an easy way to pass data among pages. Most MVVM frameworks I've seen re-implement these features in various ways.

是否有避免使用 NavigationWindow 和 Page 的具体原因?

Is there a specific reason to avoid using NavigationWindow and Page?

推荐答案

"NavigationWindow 不存储内容对象的实例导航历史.反而,NavigationWindow 创建一个新的每个内容对象的实例使用它导航到的时间导航历史.这种行为是旨在避免过多的内存消费量大时大量内容正在导航到.因此,国家的内容不被记住一个导航到下一个.然而,WPF 通过以下方式提供了几种技术你可以存储一个状态导航中的一段内容历史……"

"NavigationWindow does not store an instance of a content object in navigation history. Instead, NavigationWindow creates a new instance of the content object each time it is navigated to by using navigation history. This behavior is designed to avoid excessive memory consumption when large numbers and large pieces of content are being navigated to. Consequently, the state of the content is not remembered from one navigation to the next. However, WPF provides several techniques by which you can store a piece of state for a piece of content in navigation history...."

http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationwindow.aspx

这篇关于什么时候应该使用 UserControl 而不是 Page?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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