您的位置:首页 > 其它

Prism5.0新内容 What's New in Prism Library 5.0 for WPF(英汉对照版)

2020-06-03 05:04 465 查看

    Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF, new and updated QuickStarts, and updated documentation. Parts of the Prism Library changed between Prism 4.1 and Prism 5.0 to support the new guidance, fix existing issues, and respond to community requests.

    Prism 5.0 包含很多新东西,新的快速入门示例,新的范例,更新的文档,Prism类库代码的改变。用来解决已有问题,回应社区所提的需求。(这句话跟 What's New in Prism Library 4.0中的第一句话一模一样,就不能来的新鲜的吗?)

Note: For Silverlight applications use Prism 4.1.

注意:在Silverlight中还得用Prism 4.1.

New Guidance 新指南

Prism 5.0 contains several areas of new guidance as follows:

Prism5.0包含以下新指南:

  • Prism.Mvvm is a portable class library that encapsulates Prism’s MVVM support. This library includes ViewModelLocationProvider. Views and view models can be wired up together using the new ViewModelLocationProvider’s convention-based approach as explained in Implementing the MVVM Pattern. View model construction can be accomplished using a dependency injection container. The ViewModel Locator’s extensibility points are discussed in Extending the Prism LibraryDelegateCommands are now extendable and provide Async support. A new implementation of theINotifyPropertyChanged interface, the BindabaleBase class, was added.
         Prism.Mvvm是一个跨平台的类库,它封装了Prism对MVVM模式的支持。类库中包含ViewModelLocationProvider。视图和视图模型使用了ViewModelLocationProvider中的一个基于转换的方法进行连接,这在 实现MVVM模式 中有介绍。 视图模型可以使用依赖注入容器构造。视图模型定位器的可扩展性会在 扩展Prism介绍。DelegateCommands 现在可以支持异步。还添加一个全新 INotifyPropertyChanged 接口和 BindabaleBase 类。
  • The PopupWindowAction class was added to the Prism.Interactivity assembly to open a custom window in response to an interaction request being raised.
    The InvokeCommandAction action provided by Prism now passes trigger parameters to the associated command. For more information see Advanced MVVM Scenarios.
         PopupWindowAction 类被添加在Prism.Interactivity 程序集中。用来响应打开一个自定义窗口的交互操作。更多信息可看 进击的MVVM.
  • The EventAggregator classes have been moved to the Prism.PubSubEvents portable class library.
          EventAggregator 类转到Prism.PubSubEvents 这个跨平台的类库中了。
  • The NavigationParameters class can now be used to pass object parameters during navigation, using the overloads of the RequestNavigate method of a Region or RegionManager instance.
         NavigationParameters 类可以在导航期间传递一组object类型的参数。你将在Region 或RegionManager 实例中的方法RequestNavigate 的一个重载中使用到。

Changes in the Prism Library Prism库的改变

Prism Library 5.0 includes changes related to new functionality, code organization, and APIs.

Prism5.0库的改变包括增加了新功能,代码组织方式,和APIs.

Code Organization 代码组织

The following organizational changes were made to the library:

下面是库中代码的一些变化:

  • The Microsoft.Practices.Prism.PubSubEvents portable class library contains PubSubEventsEventAggregator and related classes.
        Microsoft.Practices.Prism.PubSubEvents 跨平台类库包含PubSubEventsEventAggregator 和一些相关的类。
  • The Microsoft.Practices.Prism.Mvvm portable class library contains ViewModelLocationProviderBindableBaseErrorsContainer, PropertySupport, CompositeCommand, DelegateCommand, DelegateCommandBase, and WeakEventHandlerManager.
        Microsoft.Practices.Prism.Mvvm 跨平台类库包含s ViewModelLocationProviderBindableBaseErrorsContainer, PropertySupport, CompositeCommand, DelegateCommand, DelegateCommandBase, and WeakEventHandlerManager
  • The Microsoft.Practices.Prism.Mvvm.Desktop assembly contains the WPF ViewModelLocator attach property.
        Microsoft.Practices.Prism.Mvvm.Desktop 程序集包含ViewModelLocator 附加属性。
  • The EventAggregator classes are marked obsolete in the Prism assembly.
        EventAggregator 类被标记为过时。
  • The Silverlight and phone versions of the Prism Library were taken out. If you need these libraries download the Prism 4.1 assemblies from NuGet.
        Silverlight和phone的版本被移除了。如果你想用,还得看Prism4.1。
  • Prism and Prism.Mvvm are independent of each other but share IActiveAware. Therefore IActiveAware has been moved to Prism.SharedInterfaces.     
        Prism和Prism.Mvvm 是彼此独立的单共享了IActiveAware ,因此IActiveAware 已经移到Prism.SharedInterfaces.

    In version 5.0 of Prism, Pub Sub Eventing functionality was moved into a separate assembly (Prism.PubSubEvents). DelegateCommandCompositeCommand, and ViewModel support were moved into another assembly (Prism.Mvvm). There are many advantages to separating PubSubEvents and Mvvm from the core Prism assembly.

    在Prism5.0这个版本中,发布/订阅事件功能移到了一个单独的程序集(Prism.PubSubEvents)。     DelegateCommandCompositeCommand, 和ViewModel 的支持移动到(Prism.Mvvm)。这样的分离很有好处。

  • You can select only the functionality that you need. If you want Regions and Modularity, you use the core Prism assembly. If you want only ViewModel and commanding support, you use Prism.Mvvm. If you only want Pub Sub Eventing, you use Prism.PubSubEvents. Each assembly is smaller and easier to understand.
        你可以可选择的使用Prism的功能。如果你想要区域和模块化,你可以使用核心Prism程序集。如果你想用ViewModel 和命令支持,你可以使用Prism.Mvvm. 如果你只想使用 发布/订阅事件,使用Prism.PubSubEvents。每个程序集都更小更易理解了。
  • You can now build your Viewodel code in a portable class library that leverages Prism.Mvvm and/or Prism.PubSubEvents since both are PCLs. By putting your ViewModel code in a PCL, your ViewModel code is constrained to using dependent libraries that are platform agnostic and thus can target multiple platforms.
        你可以在跨平台类库中构建你的Viewodel ,其中你还可以使用Prism.Mvvm 和 Prism.PubSubEvents ,以为这俩也是跨平台的库。把你的ViewModel 代码放到PCL(跨平台类库)里,你的ViewModel 就需要依赖那种平台无关的程序集,以便你的代码可以针对多种平台。
  • Updates to these smaller libraries can be made more easily and quickly.
        更新这些小的程序集更加简单快速了。

API Changes API的改变

The Prism Library API changed in several key areas. The bootstrapper was heavily modified and reusable code was added to support the new areas of guidance provided in Prism.

Prism类库API有一些关键领域的改变。bootstrapper 有重大变化,一些重用代码被添加以支持Prism新功能。

MVVM and Event Aggregator Changes. MVVM和事件聚合的改变。

Moving ViewModel and EventAggregator to a PCL causes several changes to the Prism Library. These changes include the following:

移动ViewModel 和EventAggregator 到PCL(跨平台类库)引起了一些改变。改变如下:

  • The BindableBase class in Prism.Mvvm should be used instead of NotifcationObject. The NotificationObject and NotificationObject  classes are marked obsolete in the Prism assembly.
        在 Prism.Mvvm中的BindableBase 类替代NotifcationObject 。NotificationObject 和 NotificationObject 类在Prism程序集中被标记为过时。
  • When inheriting from the BindableBase class, use the SetProperty method to update the property's backing field and raise the corresponding property change event. A newOnPropertyChanged method that takes a lambda expression as a parameter has been added.
        当你的类继承自BindableBase 类,可用使用SetProperty 方法更新属性的支持字段并引起相应属性改变事件。一个新的OnPropertyChanged 方法可用以lambda表达式作为参数。
  • Use the PubSubEvents class in the Microsoft.Practices.PubSubEvents portable class library instead of CompositePresentationEvents. The classes from the Events solution folder in the Prism assembly are marked obsolete.
        使用在 Microsoft.Practices.PubSubEvents 跨平台类库的PubSubEvents 类替代CompositePresentationEvents。在事件解决方案文件夹中的类已经被标记为过时。
  • The UriQuery class was renamed to NavigationParameters, it keeps the same functionality as before, and adds support for passing object parameters.
        UriQuery 类重命名为NavigationParameters,它保存了一些之前相同的功能,添加了object类型参数的传递。
  • DelegateCommand includes support for async handlers and has been moved to the Prism.Mvvm portable class library. DelegateCommand and CompositeCommand both use theWeakEventHandlerManager to raise the CanExecuteChanged event. The WeakEventHandlerManager must be first constructed on the UI thread to properly acquire a reference to the UI thread’s SynchronizationContext.
        DelegateCommand 包含异步处理支持,并且被移动到Prism.Mvvm 跨平台类库。DelegateCommand 和CompositeCommand 都使用了theWeakEventHandlerManager 来触发CanExecuteChanged 事件。WeakEventHandlerManager 必须被第一个构造在UI线程上以便可以获得UI线程的SynchronizationContext 属性引用。
  • EventAggregator now must be constructed on the UI thread to properly acquire a reference to the UI thread’s SynchronizationContext.
        EventAggregator 现在必须构建在UI线程,这样才能获取SynchronizationContext 属性引用。
  • The WeakEventHandlerManager is now public.
        WeakEventHandlerManager 现在变为public。
  • The Execute and CanExecute methods on DelegateCommand are now marked as virtual.
        在DelegateCommand 的 Execute 和 CanExecute 方法现在被标记为virtual 。

Additions to the Prism Library Core API Prism中被添加的核心API

The following namespaces were added to the Prism Library to support the new areas of guidance added in Prism 5.0:

一些命名空间是新被添加的,为了支持新功能:

  • Microsoft.Practices.Prism.PubSubEvents was added to help you send loosely coupled message using a portable class library.
          Microsoft.Practices.Prism.PubSubEvents 帮助你发送松耦合的消息,是使用一个跨平台的类。
  • Microsoft.Practices.Prism.Mvvm was added to assist you in implementing MVVM using a portable class library and several platform specific libraries.
        Microsoft.Practices.Prism.Mvvm 帮你使用MVVM模式。是使用一个跨平台的类和一些平台相关的程序集。
  • Microsoft.Practices.Prism.SharedInterfaces has been added to share the IActiveAware interface between Prism and Prism.Mvvm assemblies, therefore the IActiveAware interface has been moved to this assembly. It is also intended for future use.
        Microsoft.Practices.Prism.SharedInterfaces 添加了 Prism 和Prism.Mvvm 共享的IActiveAware 接口。因此IActiveAware 接口已经从Prism 核心库中移除了。

CodePlex Issues Resolved CodePlex上问题的解决

  • 8532: InteractionRequestTrigger can cause memory leaks with some implementations. InteractionRequestTrigger 可以引起一些导致内存泄露的实现。
  • 9153: 'Notification' really should be an interface. 'Notification'应该是个接口
  • 9438: Navigation to an existing view. 导航到一个存在的视图。
  • 5495: Event to Command. 命令事件
  • 8101: DelegateCommand is not extendable. DelegateCommand 不可扩展
  • 5623: Make WeakEventHandlerManager public. 让WeakEventHandlerManager 公开。
  • 9906: A bug when using XAML module catalog in WPF. 当使用XAML模块目录的一个bug。
  • 7215: Issue with ModuleCatalog.CreateFromXaml for WPF application with MEF Bootstrapper. 使用 MEF Bootstrapper中ModuleCatalog.CreateFromXaml的问题。
  • 8703: RegionManager::IsInDesignMode. RegionManager::IsInDesignMode.
  • 4349: Default Region Behavior Order Problem. 默认的区域行为顺序问题。
  • 3552: Region manager in V2 fails to recognize non-WPF applications.区域管理器不识别费WPF程序。

Example Code Changes 示例代码的改变

Prism 5.0 contains eleven separate code samples that demonstrate portions of the provided guidance. Several samples from Prism 4.1 were removed or replaced, and new samples added.

Prism5.0包含了11个单独的代码示例,展示不同的功能。一些Prism4.1的示例被替换或是移除,新的示例被添加。

The following samples were added for Prism 5.0:

被添加到Prism5.0的新示例:

  • Basic MVVM QuickStart. This QuickStart shows a very simple MVVM application that uses the ViewModel Locator and show a parent and child ViewModels. For more information, see the MVVM QuickStart.
        基础 MVVM 快速入门.此示例展示了一个非常简单的使用ViewModel 定位器的MVVM应用程序。并指示了一个嵌套ViewModels 。更多信息,请看MVVM快速入门。
  • MVVM QuickStart. This QuickStart was removed for this version.
        MVVM  快速入门 .此示例已经从此版本移除。
  • MVVM Reference Implementation. This reference implementation was removed for this version.
        MVVM 参考实现. 此示例已经从此版本移除。
  • View-Switching Navigation QuickStart. This QuickStart now supports WPF. It demonstrates how to use the Prism region navigation API. For more information, see View-Switching Navigation QuickStart.
        视图切换导航快速入门 . 此示例现在支持WPF。它描述了怎样使用Prsim区域导航API。更多信息,请看 视图切换导航快速入门.
  • State-Based Navigation QuickStart. This QuickStart now supports WPF. It shows an approach that uses the Visual State Manager to define the views (states) and the allowed transitions. For more information, see State-Based Navigation QuickStart.
        基于状态导航快速入门 . 此示例现在支持WPF。它站了一个使用视图状态管理者的方法去定义视图状态并允许切换。更多信息,请看 基于状态导航快速入门
  • UI Composition QuickStart. This QuickStart now supports WPF. It replaced the View Injection QuickStart and the View Discovery QuickStart from Prism 2.0. In the current versions, both concepts are shown in one example application. For more information, see UI Composition QuickStart.
        组合式UI快速入门 .  此示例现在支持WPF。它替换了在Prism2.0中的视图注入快速入门和视图发现快速入门。当前版本下,视图发现和视图注入在同一个例子程序中体现。更多信息,请看 组合式UI快速入门.
  • Interactivity QuickStart. This new QuickStart demonstrates how to exposes an interaction request to the view through the view model. The interactions can be a popup, confirmation, custom popup, and a more complex case where the popup needs a custom view model. It also shows Prism’s InvokeCommandAction action that passes the EventArgs from the trigger, as a command parameter. For more infromation, see Interactivity QuickStart.
        交互快速入门. 这是个新的快速入门,展示了怎样暴露一个视图上的交互请求到视图模型上。当弹窗需要一个自定义视图模型时,此交互可以是一个弹窗,确认窗,自定义弹窗,或是一个更复杂的情况。它也展示了Prism的InvokeCommandAction 动作,可以从触发器传递一个作为命令参数的EventArgs 。更多信息,请看 交互快速入门

NuGet Packages Now Available 目前可用的NuGet包

In your application, you can now use NuGet to add references to the Prism assemblies. These packages include:

在你的应用程序,你可以使用NuGet添加Prism程序集的引用。包里包括:

Note:注意
The Prism NuGet package will download the Prism.Composition, Prism.Interactivity, Prism.Mvvm, and Prism.PubSubEvents packages. You only need to add references to the Prism.Interactivity, Prism.Mvvm, and Prism.PubSubEvents if you need finer granularity.
Prism NuGet包将下载 Prism.Composition, Prism.Interactivity, Prism.Mvvm, and Prism.PubSubEvents包。你也可以单独添加Prism.Interactivity, Prism.Mvvm, 和Prism.PubSubEvents 引用。

More Information 更多信息

For more information about how to upgrade a solution from version 4.1 to version 5.0 of the Prism Library, see Upgrading from Prism Library 4.1.

如果你想了解从Prism4.1升级到Prism5.0。请看从Prism 4.1升级.

Next Topic | Previous Topic | Home | Community 下一篇 | 前一篇 | 主页 | 社区

转载于:https://www.cnblogs.com/DoubleChen/p/3682503.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: