自定义对话框窗口棱镜 [英] Customize Dialog window prism
问题描述
我已经实现了新的 DialogService,如本期所示WPF 的新 IDialogService
I have implemented the new DialogService as shown in this issue A New IDialogService for WPF
然而,这并没有解释如何编辑对话框本身的窗口,因为 NotificationDialog
是一个 UserControl
.
However, this doesn't explain how to edit the window of the dialog itself, since the NotificationDialog
is a UserControl
.
我尝试将其更改为 Window
,但由于不是根窗口而引发异常.
I have tried changing it to a Window
but then an exception is raised due to not being the root Window.
知道如何更改对话框的窗口吗?
由于标题和图标是在 DialogViewModelBase
中设置的,我也尝试添加一个 ResizeMode
属性.
Since the Title and the Icon is set in DialogViewModelBase
, I have tried to add a ResizeMode
property as well.
在DialogViewModelBase
中:
private ResizeMode _resizeMode;
public ResizeMode ResizeMode
{
get => _resizeMode;
set => SetProperty(ref _resizeMode, value);
}
和在 NotificationDialogViewModel
实现中:
public NotificationDialogViewModel()
{
Title = "Notification";
ResizeMode = System.Windows.ResizeMode.CanMinimize;
CloseDialogCommand = new DelegateCommand(CloseDialog);
}
但是它不能按预期工作.
However it doesn't work as intended.
推荐答案
知道如何更改对话框的窗口吗?
Any idea how can I change the Window of the dialog?
查看 code,看来您必须实现 IDialogWindow
并将默认注册覆盖到内置实现中.
Looking at the code, it looks like you have to implement IDialogWindow
and override the default registration to the built-in implementation.
另外,你不需要继承DialogViewModelBase
,只需要实现IDialogAware
就足够了.
Also, you don't need to inherit from DialogViewModelBase
, just implementing IDialogAware
suffices.
这篇关于自定义对话框窗口棱镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!