public DialogButtonViewModel(UICommand customUICommand, ICommand command) { this.UICommand = customUICommand; this.Content = customUICommand.Caption; this.Command = command; CanExecute = true; if(UICommand.Command != null) { CanExecute = UICommand.Command.CanExecute(null); UICommand.Command.CanExecuteChanged += CanExecuteChanged; } }
public async Task<UICommand> ShowAsync() { Popup = new Popup(); Popup.Width = Window.Current.CoreWindow.Bounds.Width; Popup.Height = Window.Current.CoreWindow.Bounds.Height; Window.Current.CoreWindow.SizeChanged += CoreWindow_SizeChanged; Result = null; DialogResultCommand = new DevExpress.Mvvm.DelegateCommand<object>(OnDialogResult); List<DialogButtonViewModel> buttons = new List<DialogButtonViewModel>(); foreach(UICommand command in CommandsSource) { buttons.Add(new DialogButtonViewModel(command, DialogResultCommand)); } Buttons = buttons; Popup.Child = this; Width = Popup.Width; Height = Popup.Height; KeyDown += DialogContentControl_KeyDown; Popup.VerticalOffset = 0; Popup.HorizontalOffset = 0; Popup.IsOpen = true; Focus(FocusState.Programmatic); await WaitPopupClosing(); return Result; }
void OnDialogResult(object parameter) { if(!Close()) return; if(parameter is UICommand) { UICommand command = (UICommand)parameter; command.Command.If(x => x.CanExecute(command)).Do(x => x.Execute(command)); Result = command; } }
public DialogButtonViewModel(UICommand customUICommand, ICommand command) { this.UICommand = customUICommand; this.Content = customUICommand.Caption; this.Command = command; }