Prism 图书馆对话服务

Prism Library Dialog Service

以下示例对我没有用: https://prismlibrary.com/docs/wpf/dialog-service.html

dialogService 来自哪里?

public MainWindowViewModel(IDialogService dialogService)
{
    _dialogService = dialogService;
}

如何添加对话服务?

protected override Window CreateShell()
    {
        var w = Container.Resolve<MainWindow>();
        return w;
    }

它必须在 RegisterTypes 中吗?

Where the dialogService comming from?

来自容器。解析时,容器也会解析所有依赖项。

How can I add the dialog service?

您不必这样做,通常也不应该这样做。大多数时候,prism 框架提供的默认实现就足够了。

It's have to go within the RegisterTypes?

如果您使用 Unity,则必须注册每个非具体类型才能解析。这意味着,Prism 的对话服务实现已在某处注册。查看您的应用程序基础 class 的代码作为起点。