Skip to main content
A newer version of this page is available. .

DXMessageBoxService Class

Allows you to display message boxes.

Namespace: DevExpress.Xpf.Core

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

Declaration

[TargetType(typeof(Window))]
[TargetType(typeof(UserControl))]
public class DXMessageBoxService :
    ServiceBase,
    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.

Example

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;
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DXMessageBoxService class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Show 11 items
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