Skip to main content

CurrentDialogService

  • 2 minutes to read

The CurrentDialogService allows you to control the associated dialog window and specify the dialog result in the Close method at the View Model level. The CurrentDialogService implements the ICurrentDialogService interface.

The table below lists the Close method overloads:

Method Action
Close(MessageResult dialogResult) Closes the associated dialog window with a specified result of the MessageResult type
Close(UICommand dialogResult) Closes the associated dialog window with a specified result of the UICommand type and invokes UICommand.Command. You can use only one of the UICommands that were initially passed to the dialog service in the ShowDialog method.

Example

View Example

<UserControl
    x:Class="DialogServiceExample.Views.SimpleDialogView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm">

    <dxmvvm:Interaction.Behaviors>
        <dx:CurrentDialogService />
    </dxmvvm:Interaction.Behaviors>

    <StackPanel>
        <ComboBox SelectedItem="{Binding DialogResult}">
            <ComboBox.Items>
                <dxmvvm:MessageResult>Yes</dxmvvm:MessageResult>
                <dxmvvm:MessageResult>No</dxmvvm:MessageResult>
                <dxmvvm:MessageResult>Cancel</dxmvvm:MessageResult>
            </ComboBox.Items>
        </ComboBox>
        <Button Command="{Binding CloseCommand}" Content="Close the dialog from the dialog view model" />
    </StackPanel>

</UserControl>
See Also