DevExpress Services passes commands from the ViewModel to controls in the View, which allows you to modify the UI without detaching the application layer.
Get tool download - devaexpress v21 two
DialogService
Allows you to display a dialog box.
Interface
Managed control
Global registration
C#
MVVMContext.RegisterXtraDialogService(); MVVMContext.RegisterFlyoutDialogService(); MVVMContext.RegisterRibbonDialogService();
VB.NET
MVVMContext.RegisterXtraDialogService() MVVMContext.RegisterFlyoutDialogService() MVVMContext.RegisterRibbonDialogService()
DevExpress The MVVM framework automatically calls the RegisterXtraDialogService method.
Local registration
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() method
All 'Create...' methods of DialogService need a View with the service. If you pass null instead of View, the framework will try to locate the appropriate window (in most cases, use the activation window).
- Create (iwin32window owner, DefaultDialogServiceType) - use the DefaultDialogServiceType enumerator value to determine the type of service to create.
- CreateXtraDialogService(IWin32Window owner) - create a display skinnable Services for the devaxpress dialog box.
- CreateFlyoutDialogService(IWin32Window owner) - create a display FlyoutDialog Services.
- CreateRibbonDialogService(IWin32Window owner) - create one with embedded RibbonControl s RibbonForm s is displayed as the service of the dialog box, and the dialog box button is displayed as a ribbon item.
- Create (iwin32window owner, string title, func < IDialogForm > factorymethod) - allows you to register a service that manages custom dialog boxes (objects that implement the IDialogForm interface).
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) - factory class that accepts the creation of custom dialog boxes.
Public service method
- ShowDialog - six extension methods to display dialog boxes with specific appearance and content.
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
These overloads allow you to replace the default dialog button with a custom UICommand object. To do this, use the Id or Tag property of the custom command as the MessageResult or DialogResult value.
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 - allows you to access the dialog box and modify its appearance settings. For example, the following code shows how to apply a bold font style to a pop-up dialog button.
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
Devaxpress WinForm | download trial
DevExpress WinForm With 180 + components and UI libraries, it can create influential business solutions for the Windows Forms platform. Devaxpress WinForms can perfectly build smooth, beautiful and easy-to-use applications. It can be easily competent in both Office style interface and analyzing and processing large quantities of business data!
Devaxpress technical exchange group 5:742234706 welcome to join the group discussion