Skip to main content

UICommand Class

A ViewModel that is used to generate a dialog button.

Namespace: DevExpress.Mvvm

Assembly: DevExpress.Mvvm.v23.2.dll

NuGet Packages: DevExpress.Mvvm, DevExpress.Win.Navigation

Declaration

public class UICommand :
    BindableBase,
    IUICommand

Remarks

The code sample below shows how to define dialog buttons:

UICommand registerCommand = new UICommand(
    id: null,
    caption: "Register",
    command: new DelegateCommand<CancelEventArgs>(
        cancelArgs => {
            try {
                myExecuteMethod();
            }
            catch (Exception e) {
                this.GetService<IMessageBoxService>().ShowMessage(e.Message, "Error", MessageButton.OK);
                cancelArgs.Cancel = true;
            }
        },
        cancelArgs => !string.IsNullOrEmpty(registrationViewModel.UserName)
    ),
    isDefault: true,
    isCancel: false
);

UICommand cancelCommand = new UICommand(
    id: MessageBoxResult.Cancel,
    caption: "Cancel",
    command: null,
    isDefault: false,
    isCancel: true
);

IDialogService service = this.GetService<IDialogService>(serviceName);
UICommand result = service.ShowDialog(
    dialogCommands: new[] { registerCommand, cancelCommand },
    title: "Registration Dialog",
    viewModel: detailViewModel
);

View Example: How to: Use DialogService

Inheritance

See Also