什么时候应该使用 UserControl 而不是 Page?

编程入门 行业动态 更新时间:2024-10-09 19:13:58
本文介绍了什么时候应该使用 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...."

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

更多推荐

什么时候应该使用 UserControl 而不是 Page?

本文发布于:2023-11-29 04:18:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:什么时候   而不是   UserControl   Page

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!