将视图显示为对话框

Show View as a dialog box

我使用 devexpress 混合 wpf 脚手架向导生成了一个完整的 MVVM

具有集合视图和单个对象视图的应用程序。

现在我正在努力弄清楚如何在从集合视图中双击时弹出一些单个对象视图,作为 metroUI 对话框而不是带有后退按钮的框架。

我建议您使用 IDialogSerivice and it's WinUIDialogService 实现来完成此任务。 由于您正在使用 scaffolding,您应该进入 collection 视图 (YouEntityCollectionView.xaml) 并进入 Behaviors 部分:

<dxmvvm:Interaction.Behaviors>
    <dxwui:WinUIMessageBoxService/>
    <dxmvvm:EventToCommand Command="{Binding OnLoadedCommand}" />
    <WindowedDocumentUIService YieldToParent="True"/>
</dxmvvm:Interaction.Behaviors>

然后将您的服务添加到此部分:

<dxmvvm:Interaction.Behaviors>
    <dxwui:WinUIMessageBoxService/>
    <dxmvvm:EventToCommand Command="{Binding OnLoadedCommand}" />
    <dxwui:WinUIDialogService />
</dxmvvm:Interaction.Behaviors>

之后,您应该将 CollectionViewModel 代码中的 IDocumentManagerService 替换为 IDialogService。它可能如下所示:

// Edit:
//DocumentManagerService.ShowExistingEntityDocument<TEntity, TPrimaryKey>(this, primaryKey);
this.GetService<IDialogService>().ShowDialog(MessageButton.OKCancel, null, typeof(TEntity).Name + "View", primaryKey, this);

// New:
//DocumentManagerService.ShowNewEntityDocument(this, newEntityInitializer);
this.GetService<IDialogService>().ShowDialog(MessageButton.OKCancel, null, typeof(TEntity).Name + "View", newEntityInitializer, this);