public EditQueryViewModel(SearchQuery target) : base("検索条件編集") { this.Title = new ReactiveProperty<string>() .SetValidateError(s => string.IsNullOrWhiteSpace(s) ? "タイトルを入力してください" : null); this.Query = new ReactiveProperty<string>() .SetValidateError(s => string.IsNullOrWhiteSpace(s) ? "クエリを入力してください" : null); this.Title.Value = target.Title; this.Query.Value = target.Query; this.CancelCommand = new ReactiveCommand(); this.CancelCommand.Subscribe(_ => { this.NavigateRequest.Raise(new NavigateNotification(true)); }); this.CommitCommand = Observable.Merge( this.Title.Do(_ => this.Title.ForceValidate()).Select(_ => Unit.Default), this.Query.Do(_ => this.Query.ForceValidate()).Select(_ => Unit.Default)) .Select(_ => string.IsNullOrWhiteSpace(this.Title.Error) && string.IsNullOrWhiteSpace(this.Query.Error)) .ToReactiveCommand(); this.CommitCommand.Subscribe(_ => { target.Title = this.Title.Value; target.Query = this.Query.Value; this.NavigateRequest.Raise(new NavigateNotification(true)); }); }
public SearchQueryViewModel(MainPageViewModel parent, SearchQuery model) { this.Parent = new ReactiveProperty<MainPageViewModel>(parent); this.Model = new ReactiveProperty<SearchQuery>(model); this.Title = this.Model.Value .ObserveProperty(o => o.Title) .ToReactiveProperty(this.Model.Value.Title); this.Query = this.Model.Value .ObserveProperty(o => o.Query) .ToReactiveProperty(this.Model.Value.Query); this.SearchCommand = new ReactiveCommand(); this.SearchCommand.Subscribe(_ => { var vm = new SearchViewViewModel(this.Model.Value); vm.QueryCommand.Execute(null); this.Parent.Value.SelectedQuery.Value = vm; this.Parent.Value.NavigateRequest.Raise( new NavigateNotification(new Uri("/SearchViewPage.xaml", UriKind.Relative))); }); }
public void TearDown() { this.target = null; }
public void SeUp() { this.target = new SearchQuery(); }