【发布时间】:2021-11-04 21:28:00
【问题描述】:
在 Prism 库网站上有一些关于简化应用程序对话框 API 的说明。 https://prismlibrary.com/docs/wpf/dialog-service.html
假设我有一个包含多个项目的解决方案,MainProject、Modules.Module1、CoreProject。所以在我的核心项目中创建这个DialogServiceExtensions 类。
public static class DialogServiceExtensions
{
public static void ShowNotification(this IDialogService dialogService, string message, Action<IDialogResult> callBack)
{
dialogService.ShowDialog(nameof(NotificationDialog), new DialogParameters($"message={message}"), callBack, "notificationWindow");
}
}
我还将NotificationDialog 和NotificationDialogViewModel 放在我的核心项目中
我可以在任何项目/模块中调用它,但问题是我如何告诉 prism NotificationDialog ViewModel 是 NotificationDialogViewModel。
我应该在哪里注册对话框,以便能够通过孔解决方案使用?像往常一样在我的 MainProject App.xaml.cs 中?
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterDialog<NotificationDialog, NotificationDialogViewModel>();
}
【问题讨论】: