DXMessageBoxService Class
Allows you to display message boxes.
Namespace: DevExpress.Xpf.Core
Assembly: DevExpress.Xpf.Core.v24.2.dll
NuGet Package: DevExpress.Wpf.Core
#Declaration
[TargetType(typeof(Window))]
[TargetType(typeof(UserControl))]
public class DXMessageBoxService :
ServiceBase,
IMessageBoxService
#Remarks
Note
DXMessage
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;
}
}
}
#Related GitHub Examples
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.