UI组件DevExpress WinForm入门指南 - DialogService服务
DevExpress Services将命令从ViewModel传递到View中的控件,这允许您在不分离应用程序层的情况下修改 UI。
获取工具下载 - DevExpress v21.2
DialogService
允许您显示对话框。
接口
IDialogService
托管控件
- XtraForm
- FlyoutDialog
- RibbonForm
全局注册
C#
MVVMContext.RegisterXtraDialogService();
MVVMContext.RegisterFlyoutDialogService();
MVVMContext.RegisterRibbonDialogService();
VB.NET
MVVMContext.RegisterXtraDialogService()
MVVMContext.RegisterFlyoutDialogService()
MVVMContext.RegisterRibbonDialogService()
DevExpress MVVM 框架自动调用 RegisterXtraDialogService 方法。
本地注册
C#
mvvmContext1.RegisterService(DialogService.CreateXtraDialogService(this));
mvvmContext1.RegisterService(DialogService.CreateFlyoutDialogService(this));
mvvmContext1.RegisterService(DialogService.CreateRibbonDialogService(this));
mvvmContext1.RegisterService(DialogService.Create(this, DefaultDialogServiceType.RibbonDialog));
VB.NET
mvvmContext1.RegisterService(DialogService.CreateXtraDialogService(Me))
mvvmContext1.RegisterService(DialogService.CreateFlyoutDialogService(Me))
mvvmContext1.RegisterService(DialogService.CreateRibbonDialogService(Me))
mvvmContext1.RegisterService(DialogService.Create(Me, DefaultDialogServiceType.RibbonDialog))
Create() 方法
DialogService 的所有‘Create…’方法都需要一个拥有该服务的视图,如果您传递 null 而不是 View,框架会尝试定位适当的窗口(在大多数情况下,使用激活窗口)。
- Create(IWin32Window owner, DefaultDialogServiceType type) - 使用 DefaultDialogServiceType 枚举器值来确定要创建的服务类型。
- CreateXtraDialogService(IWin32Window owner) - 创建一个显示skinnable DevExpress 对话框的服务。
- CreateFlyoutDialogService(IWin32Window owner) - 创建一个显示FlyoutDialog 的服务。
- CreateRibbonDialogService(IWin32Window owner) - 创建一个将带有嵌入式RibbonControls的RibbonForms 显示为对话框的服务,对话框按钮显示为功能区项目。
- Create(IWin32Window owner, string title, Func<IDialogForm> factoryMethod) - 允许您注册管理自定义对话框(实现 IDialogForm 接口的对象)的服务。
C#
DialogService.Create(ownerView1, "A custom dialog", ()=> new CustomDialogClass());
VB.NET
DialogService.Create(ownerView1, "A custom dialog", Function() New CustomDialogClass())
- DialogService Create(IWin32Window owner, string title, IDialogFormFactory factory) - 接受创建自定义对话框的工厂类。
公共服务方法
- ShowDialog - 六个扩展方法,显示具有特定外观和内容的对话框。
C#
public void FindCustomer() {
if(DialogService.ShowDialog(MessageButton.OKCancel, "Find Customer", findDialogViewModel) == MessageResult.OK) {
// do something
}
}
VB.NET
Public Sub FindCustomer()
If DialogService.ShowDialog(MessageButton.OKCancel, "Find Customer", findDialogViewModel) = MessageResult.OK Then
' do something
End If
End Sub
这些重载允许您用自定义 UICommand 对象替换默认对话框按钮。 为此,请将自定义命令的 Id 或 Tag 属性用作 MessageResult 或 DialogResult 值。
C#
public void FindCustomer() {
var findDialogViewModel = FindDialogViewModel.Create();
findDialogViewModel.SetParentViewModel(this);
var commands = new List<UICommand>
{
// Button with custom command attached
new UICommand {
Id = "Find",
Caption = "Find",
Command = new DelegateCommand(() =>{
// . . . implement the Find command here
}),
IsDefault = true,
IsCancel = false,
Tag = DialogResult.OK
},
// standard button caption customization
new UICommand {
Caption = "Cancel Find",
Tag = DialogResult.Cancel
}
};
DialogService.ShowDialog(commands, "Find Customer", "FindDialogView", SelectedEntity, findDialogViewModel);
}
VB.NET
Public Sub FindCustomer()
Dim findDialogViewModel = FindDialogViewModel.Create()
findDialogViewModel.SetParentViewModel(Me)
Dim commands = New List(Of UICommand) From {New UICommand With {.Id = "Find", .Caption = "Find", .Command = New DelegateCommand(Sub()
End Sub), .IsDefault = True, .IsCancel = False, .Tag = DialogResult.OK
},
New UICommand With {.Caption = "Cancel Find", .Tag = DialogResult.Cancel}
}
DialogService.ShowDialog(commands, "Find Customer", "FindDialogView", SelectedEntity, findDialogViewModel)
End Sub
- DialogFormStyle - 允许您访问对话框并修改其外观设置。 例如,下面的代码说明了如何将粗体字体样式应用于弹出对话框按钮。
C#
var service = DialogService.CreateFlyoutDialogService(this);
service.DialogFormStyle = (form) =>
{
FlyoutDialog dialog = form as FlyoutDialog;
dialog.Properties.AppearanceButtons.FontStyleDelta = FontStyle.Bold;
};
VB.NET
Dim service = DialogService.CreateFlyoutDialogService(Me)
service.DialogFormStyle = Sub(form)
Dim dialog As FlyoutDialog = TryCast(form, FlyoutDialog)
dialog.Properties.AppearanceButtons.FontStyleDelta = FontStyle.Bold
End Sub
DevExpress WinForm | 下载试用
DevExpress WinForm拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案。DevExpress WinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!
DevExpress技术交流群5:742234706 欢迎一起进群讨论
DevExpress线上公开课主题票选火热开启,主题由你来定!点击填写问卷
UI组件DevExpress WinForm入门指南 - DialogService服务相关推荐
- UI组件Kendo UI for jQuery数据管理入门指南 - TaskBoard/卡片
Kendo UI TaskBoard将任务.笔记.项目或其他类型的项目显示为按列(通道)中特定标准分组的卡片,卡片可以重新排序.放到另一列.编辑或删除. Kendo UI for jQuery最新官方 ...
- UI组件库Kendo UI for Vue中文入门指南(四)
在本文中,您将通过构建一个包含 Grid.DropDownList.Window 和设计主题的小应用程序来学习如何使用Kendo UI for Vue组件. Kendo UI最新官方正式版下载 7. ...
- UI组件库Kendo UI for Vue中文入门指南(二)
在本文中,您将通过构建一个包含 Grid.DropDownList.Window 和设计主题的小应用程序来学习如何使用Kendo UI for Vue组件. Kendo UI最新官方正式版下载 5. ...
- UI组件库Kendo UI for Vue中文入门指南(一)
在本文中,您将通过构建一个包含 Grid.DropDownList.Window 和设计主题的小应用程序来学习如何使用Kendo UI for Vue组件. Kendo UI最新官方正式版下载 1. ...
- Kendo UI使用教程:入门指南
[Kendo UI最新试用版下载] Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support for React和 ...
- UI设计师零基础入门指南(附2019最新UI设计学习线路图)
对于UI设计新手而言,想要快速入门,就需要弄明白UI设计是什么?需要学习哪些内容?然后根据自己的学习目制定明确的学习计划和学习路线,按照科学系统的方法,由浅入深,循序渐进的进行能力提升,唯有如此才能快 ...
- nacos enablediscoveryclient_Nacos入门指南03 服务发现实践
你好,欢迎阅读,本文是系列文章中的第3篇. Part1 - Nacos 是什么? Part2 - Nacos 环境搭建 Part3 - Nacos 服务发现实践 Part4 - Nacos 分布式配置 ...
- 12 个不可错过的 Vue UI 组件库,请查收
1. Element UI Element UI 是一套为开发者.设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库.它是一个用于 Web 的 UI 组件库 ,除了 Vue 之外,它还具有Re ...
- 12个Vue UI 组件库
Vue.js 是一个渐进式 javascript 框架,用于构建 UIS(用户界面)和 SPA(单页应用程序).UI 组件库提高了我们的开发效率,增强了应用的整体外观.感觉.交互性和可访问性,下面就来 ...
- Android之React native的介绍和入门指南
链接:http://zhuanlan.zhihu.com/FrontendMagazine/19996445 数月前,Facebook 对外宣布了正在开发的 React Native 框架,这个框架允 ...
最新文章
- 最近邻插值实现:图像任意尺寸变换
- ios学习笔记——Block块小结
- 用OpenJTAG烧写程序到Flash—— 韦东山嵌入式Linux视频学习笔记03
- mysql必知必会_MySQL必知必会
- idea连接mysql怎么生成实体类_IDEA链接数据库自动生成实体类
- ​2020启示:拼多多篇— —退潮后,你才发现人家是游泳健将
- 电脑应用程序错误怎么办_电脑Windows出错信息解析及解决方案
- 《R语言数据挖掘:实用项目解析》——2.6 变量分段
- csrf防御 php,跨站请求伪造CSRF的防御实例(PHP版本)
- 开源cms系统We7插件开发准备工作全面就绪
- LintCode 二叉树的最小深度
- 利用Python代码完成Fisher判别的推导
- 计算机应用能力考试ppt2003,全国专业技术人员计算机应用能力考试_PPT_2003_题库版.docx...
- 模仿探探(百合网,珍爱网)卡片左右滑动效果,滑动流畅,卡片view无限重生
- AprilTags图像识别定位实例
- 2021全国特种设备-Q2起重机司机模拟考试题库一[安考星]
- sql面试题,查询出每班每科最高分的学生
- [机缘参悟-14]:哲学、唯物主义、唯心主义与空无主义
- 【富集分析】GO KEGG
- 多线程和事务之Workaround