public ReactivePropertyViewModel(IShelfBoxRepository shelfBoxRepository) { _shelfBoxRepository = shelfBoxRepository; BoxDatas = new ObservableCollection <BoxDataEntity>(_shelfBoxRepository.GetBoxAll()); BoxDatas2.Value = new ObservableCollection <BoxDataEntity>(_shelfBoxRepository.GetBoxAll()); Name.Value = "akiraFirst"; //Index2.Subscribe(x => Console.WriteLine($"Subscribe: {x}")).AddTo(this.Disposable); // 1個 Subscribe: 初期値 Index2.Subscribe(x => { Console.WriteLine($"Subscribe: {x}"); Index = x; }).AddTo(this.Disposable); // いろいろ行う Subscribe: 初期値 //NameTest = new ReactiveProperty<string>() //.SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "空文字はダメ" : null); NameTest = new ReactiveProperty <string>(mode: ReactivePropertyMode.Default | ReactivePropertyMode.IgnoreInitialValidationError) .SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "空文字はダメ" : null).AddTo(this.Disposable);; // デフォルト値が true の設定 IsChecked = new ReactivePropertySlim <bool>(true).AddTo(this.Disposable); // ReactiveProperty は IObservable なので ReactiveCommand にできる SampleCommand = IsChecked.ToReactiveCommand().AddTo(this.Disposable); // ReactiveCommand は IObservable なので Select で加工して ReactiveProperty に出来る Message = SampleCommand.Select(_ => DateTime.Now.ToString()) .ToReadOnlyReactivePropertySlim().AddTo(this.Disposable); ButtonCommand.Subscribe(_ => ButtonAction()); this.Input = new ReactiveProperty <string>(""); // デフォルト値を指定してReactivePropertyを作成 this.Output = this.Input .Delay(TimeSpan.FromSeconds(1)) // 1秒間待機して .Select(x => x.ToUpper()) // 大文字に変換して .ToReactiveProperty(); // ReactiveProperty化する }