Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
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.
<UserControlx: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><ComboBoxSelectedItem="{Binding DialogResult}"><ComboBox.Items><dxmvvm:MessageResult>Yes</dxmvvm:MessageResult><dxmvvm:MessageResult>No</dxmvvm:MessageResult><dxmvvm:MessageResult>Cancel</dxmvvm:MessageResult></ComboBox.Items></ComboBox><ButtonCommand="{Binding CloseCommand}"Content="Close the dialog from the dialog view model" /></StackPanel></UserControl>
usingDevExpress.Mvvm;
usingSystem.Windows.Input;
namespaceDialogServiceExample.ViewModels {
publicclassSimpleDialogViewModel : ViewModelBase {
public MessageResult DialogResult {
get { return GetProperty(() => DialogResult); }
set { SetProperty(() => DialogResult, value); }
}
public ICommand CloseCommand { get; privateset; }
protected ICurrentDialogService CurrentDialogService { get { return GetService<ICurrentDialogService>(); } }
publicSimpleDialogViewModel() {
CloseCommand = new DelegateCommand<MessageResult>(Close);
}
publicvoidClose(MessageResult parameter) {
CurrentDialogService.Close(DialogResult);
}
}
}
ImportsDevExpress.MvvmNamespace DialogServiceExample.ViewModels
PublicClass SimpleDialogViewModel
Inherits ViewModelBase
PublicProperty DialogResult() As MessageResult
GetReturn GetProperty(Function() DialogResult)
EndGetSet(ByVal value As MessageResult)
SetProperty(Function() DialogResult, value)
EndSetEndPropertyPublicProperty CloseCommand() As ICommand
ProtectedReadOnlyProperty CurrentDialogService() As ICurrentDialogService
GetReturn GetService(Of ICurrentDialogService)()
EndGetEndPropertyPublicSubNew()
CloseCommand = New DelegateCommand(Of MessageResult)(AddressOf Close)
EndSubPublicSub Close(ByVal parameter As MessageResult)
CurrentDialogService.Close(DialogResult)
EndSubEndClassEndNamespace