csharpshare.com
Show / Hide Table of Contents

从Prism 7.x版本进行迁移

Gitee仓库 Prism-Documentation-CH 时间 2023-1-21

将您的应用程序从Prism 7.x迁移到8.x应该非常简单,但是您也应该注意到一些例外的情况,这些例外情况可能会影响到您的应用程序功能。

AutoWireViewModel的修改

在过去,您可能会在所有Views中重复此样板代码:

<Window
    x:Class="Application1.Views.AppWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Bbsw.VaultToForge.Ux.Views"
    xmlns:prism="http://prismlibrary.com/"
    prism:ViewModelLocator.AutoWireViewModel="True"
>
...
</Window>

AutoWireViewModel现在默认为true。如果您像上面那样使用ViewModelLocator,则不应有任何更改。但是如果您对ViewModels做了一些不同的事情,也许是将它们添加为构造函数中的依赖项等,则需要关闭AutoWireViewModel。

<Window
    x:Class="Application1.Views.AppWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Bbsw.VaultToForge.Ux.Views"
    xmlns:prism="http://prismlibrary.com/"
    prism:ViewModelLocator.AutoWireViewModel="False"
>
...
</Window>

ILoggerFacade已从Prism.Core中移除

所有日志相关的功能都已从Prism.Core中删除。推荐的迁移方式是使用Prism.Plugin.Logging或者任何你喜欢的第三方日志框架。关于Prism.Plugin入门的资源,可以在这里找到。

Container Service Locator

新的ContainerLocator已添加到Prism.Core中,它取代了Prism.Wpf中的Common Service Locator的功能。

所有的版本说明

可以在此处找到所有Prism 8相关的版本说明。

本文导航
返回顶部 ©2022-2023 csharpshare.com    冀ICP备2022026743号-1     公安备案图标 冀公网安备 13052902000206号     Icons by Icons8