public ButtonCellTestViewModel(IPageDialogService pageDialog) { CanExecute.Value = CanExecutes[0]; Commands[0] = CanExecute.ToReactiveCommand(); Commands[1] = CanExecute.ToReactiveCommand(); CommandParameter.Value = Parameters[0]; Command.Value = Commands[0]; Commands[0].Subscribe(async p => { await pageDialog.DisplayAlertAsync("Command1", p?.ToString(), "OK"); }); Commands[1].Subscribe(async p => { await pageDialog.DisplayAlertAsync("Command2", p?.ToString(), "OK"); }); }
public LabelCellTestViewModel(INavigationService navigationService, IPageDialogService pageDialog) { BackgroundColor.Value = Color.White; PickerTitle.Value = "Hoge"; TimeFormat.Value = "t"; Time.Value = new TimeSpan(12, 0, 0); DateFormat.Value = DateFormats[0]; TodayText.Value = TodayTexts[0]; Date.Value = Dates[0]; MaxDate.Value = MaxDates[0]; MinDate.Value = MinDates[0]; CanExecute.Value = CanExecutes[0]; Commands[0] = CanExecute.ToReactiveCommand(); Commands[1] = CanExecute.ToReactiveCommand(); CommandParameter.Value = Parameters[0]; Command.Value = Commands[0]; Commands[0].Subscribe(async p => { await pageDialog.DisplayAlertAsync("Command1", p?.ToString(), "OK"); await navigationService.NavigateAsync("ContentPage"); }); Commands[1].Subscribe(async p => { await pageDialog.DisplayAlertAsync("Command2", p?.ToString(), "OK"); }); NumberSelectedCommand.Subscribe(async p => { await pageDialog.DisplayAlertAsync("", p.ToString(), "OK"); }); TextSelectedCommand.Subscribe(async p => { await pageDialog.DisplayAlertAsync("", p?.ToString(), "OK"); }); }
public AddCommandPageViewModel(INavigationService navigationService) { Navigation = navigationService; EffectOn = true; EffectColor = Color.FromHex("#FFFF00"); IsExecutedCommand = false; IsExecutedLong = false; EnableRipple = true; TestParam = "Hoge"; TestLongParam = "LongHoge"; EnableSound = true; SyncCanExecute = true; ToggleCanExecute.Subscribe(_ => { CanExecute.Value = !CanExecute.Value; }); IDisposable subCommand = null; ChangeCommand.Subscribe(_ => { if (EffectCommand != null) { subCommand?.Dispose(); EffectCommand = null; } else { EffectCommand = CanExecute.ToReactiveCommand(); subCommand = EffectCommand.Subscribe(ExecCommand); } OnPropertyChanged(() => this.EffectCommand); }); ChangeCommand.Execute(); IDisposable subLongCommand = null; ChangeLongCommand.Subscribe(_ => { if (LongCommand != null) { subLongCommand.Dispose(); LongCommand = null; } else { LongCommand = CanExecute.ToReactiveCommand(); subLongCommand = LongCommand.Subscribe(ExecLongCommand); } OnPropertyChanged(() => this.LongCommand); }); ChangeLongCommand.Execute(); CanExecuteNullToggle.Subscribe(_ => { if (CanExecuteCommand != null) { CanExecuteCommand = null; CommandParameterText = "Command is null"; } else { CanExecuteCommand = CanExecute.ToAsyncReactiveCommand(); CanExecuteCommand.Subscribe(async x => { CommandParameterText = "Done Command"; await Task.Delay(500); }); } OnPropertyChanged(() => CanExecuteCommand); }); CanExecuteLongNullToggle.Subscribe(_ => { if (CanExecuteLongCommand != null) { CanExecuteLongCommand = null; CommandParameterText = "LongCommand is null"; } else { CanExecuteLongCommand = CanExecuteLong.ToReactiveCommand(); CanExecuteLongCommand.Subscribe(async x => { CommandParameterText = "Done Long Command"; await Task.Delay(500); }); } OnPropertyChanged(() => CanExecuteLongCommand); }); CanExecuteNullToggle.Execute(); CanExecuteLongNullToggle.Execute(); }