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

MessageBoxService Class

The UI service that allows you to show messages.

Namespace: DevExpress.WinUI.Core

Assembly: DevExpress.WinUI.Core.v22.1.dll

NuGet Package: DevExpress.WinUI

Declaration

public class MessageBoxService :
    UIServiceBase,
    IMessageBoxService,
    IMessageButtonLocalizer

Remarks

Run Demo: UI Services Module in the WinUI MVVM Demo

The following code sample shows a message when a user clicks the Button:

<UserControl ...
    xmlns:dx="using:DevExpress.WinUI.Core"
    xmlns:ViewModel="using:WinUIApp.ViewModel"> 
    <UserControl.DataContext>
        <ViewModel:ViewModel/>
    </UserControl.DataContext>
    <dx:Interaction.Behaviors>
        <dx:MessageBoxService/>
    </dx:Interaction.Behaviors>
    <!-- ... -->
    <Button Content="Save" Command="{x:Bind SaveCommand}"/>
</UserControl>
public class ViewModel : ViewModelBase {
    public DelegateCommand SaveCommand { get; }
    IMessageBoxService MessageBoxService => GetUIService<IMessageBoxService>();
    public ViewModel() {
        SaveCommand = new DelegateCommand(() => Save());
    }
    public async void Save() {
        MessageResult result = await MessageBoxService.ShowAsync(
            content: "Are you sure you want to save?", 
            title: "Confirmation", 
            button: MessageButton.OKCancel);
        if(result == MessageResult.OK) {
            //...
        } else {
            //...
        }
    }
}

Implements

See Also