DXMessageBoxService Class

Allows you to display message boxes.

Namespace: DevExpress.Xpf.Core

Assembly: DevExpress.Xpf.Core.v20.1.dll

Declaration

[TargetType(typeof(Window))]
[TargetType(typeof(UserControl))]
public class DXMessageBoxService :
    ServiceBase,
    IMessageBoxService
<TargetType(GetType(Window))>
<TargetType(GetType(UserControl))>
Public Class DXMessageBoxService
    Inherits ServiceBase
    Implements IMessageBoxService

Remarks

NOTE

DXMessageBoxService uses the ThemedMessageBox instead of DXMessageBox. Use the UseThemedWindowInServices compatibility property to use the DXMessageBox in this service.

See Services for more information.

Examples

The following code defines a command within a View Model that displays a message box via a dedicated Message Box service. The service is accessed via the IServiceContainer.GetService<T> method invoked on the View Model's ServiceContainer protected property. The GetService method retrieves an actual service from a View that implements the specified IMessageBoxService interface. In our example, the method will retrieve a DXMessageBoxService object defined within the View.

Services from a View can be retrieved by a ViewModel if the following conditions are met:

  • An actual service object (in this case, the DXMessageBoxService object) is added within a View to the Interaction.Behaviors collection.
  • The View's DataContext is set to your View Model.
using System;
using System.Windows.Input;
using DevExpress.Xpf.Mvvm;

public class ViewModel1 : ViewModelBase {
    //...
    ICommand showAboutCommand;

    public ICommand ShowAboutCommand {
        get {
            if (showAboutCommand == null) {
                showAboutCommand = new DelegateCommand<object>(o => {
                    ServiceContainer.GetService<IMessageBoxService>().Show("About Window");
                });
            }
            return showAboutCommand;
        }
    }
}

Inheritance

Object
DispatcherObject
DependencyObject
Freezable
Animatable
DevExpress.Mvvm.UI.Interactivity.AttachableObjectBase
DevExpress.Mvvm.UI.Interactivity.Behavior
DevExpress.Mvvm.UI.Interactivity.Behavior<FrameworkElement>
DevExpress.Mvvm.UI.ServiceBaseGeneric<FrameworkElement>
ServiceBase
DXMessageBoxService
See Also