[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Collapse]MVVM Framework
  [Expand]View Models
  [Expand]Commands
  [Expand]Behaviors
  [Collapse]Services
    Getting Started
    Services in ViewModelBase descendants
    Services in POCO objects
    Services in custom ViewModels
    View creation mechanisms
   [Collapse]Predefined Set
    [Collapse]Dialog Services
      DialogService
      WinUIDialogService
    [Expand]Message Box Services
    [Expand]Document Services
    [Expand]ViewInjectionService
    [Expand]Report Services
     NotificationService
     TaskbarButtonService
     ApplicationJumpListService
     DXSplashScreenService
     DispatcherService
     FrameNavigationService
     LayoutSerializationService
     FolderBrowserDialogService
     OpenFileDialogService
     SaveFileDialogService
     WizardService
     WindowService
     CurrentDialogService
     CurrentWindowService
     NotifyIconService
    How to create a Custom Service
  [Expand]DXBinding
  [Expand]MIF
   Converters
   ViewLocator
   Messenger
   Data Annotation Attributes
   LayoutTreeHelper
   Weak Event
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

DialogService

The DialogService allows you to show a modal dialog window (ThemedWindow (see ThemedWindow)) and gets its result.

The service implements the IDialogService interface.

Use the WinUIDialogService to display a modal window in the Windows 8/10 style.

Expanded Getting Started

Attach the Service

Use the DialogService to show a dialog from a ViewModel. Assign the DialogService service to your View in any of the following ways:

  • attach the DialogService service to a View with the Smart Tag

  • declare the DialogService service:

Access the Service

Refer to the following topics for more information on how to access a service in ViewModel:

The code sample below shows how to access the service from a ViewModel that is a ViewModelBase descendant:

Define Dialog Content

Use the DialogService.ViewTemplate property to specify the displayed dialog content.

Define Dialog Buttons

You can define dialog buttons in the following ways:

  • Pass a DevExpress.Mvvm.MessageButton enumeration value (OK, OKCancel, YesNoCancel, YesNo) to the ShowDialog method. In this case, the dialog returns the result of the DevExpress.Mvvm.MessageResult type (None, OK, Cancel, Yes, No).

  • Pass a collection of the UICommand objects to the ShowDialog method. In this case, the dialog returns a result of the UICommand type.

Refer to the Display a Dialog section below to find a list of the ShowDialog method overloads

Display a Dialog

To display a dialog with a View, use one of the IDialogService's ShowDialog extension methods depending on your MVVM architecture:

Refer to the View creation mechanisms document for more information.

The code sample below demonstrates how to show a dialog with the Register and Cancel buttons.

Expanded Adjust the Service Window

The following DialogService properties allow you to configure your service window:

  • The ViewTemplate property specifies a dialog window's template.
  • The ViewTemplateSelector property specifies a DataTemplateSelector that chooses a ViewTemplate based on custom logic.
  • The ViewLocator property specifies a ViewLocator that creates a child View based on the passed view type.
  • The DialogStyle property sets the dialog window's Style.
  • The DialogWindowStartupLocation property specifies a dialog window's startup position.

Expanded Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-dialogservice-t145641.

Expanded See Also

Is this topic helpful?​​​​​​​