예제 #1
0
        public TodoApp()
        {
            _todoItems         = new ObservableCollection <TodoItem>();
            AllTodoItems       = new ReadOnlyObservableCollection <TodoItem>(_todoItems);
            ActiveTodoItems    = AllTodoItems.ToFilteredReadOnlyObservableCollection(x => !x.Completed.Value).AddTo(_disposables);
            CompletedTodoitems = AllTodoItems.ToFilteredReadOnlyObservableCollection(x => x.Completed.Value).AddTo(_disposables);

            IsCompletedAllItems = AllTodoItems.ObserveElementProperty(x => x.Completed)
                                  .ToUnit()
                                  .Merge(AllTodoItems.CollectionChangedAsObservable().ToUnit())
                                  .Throttle(TimeSpan.FromMilliseconds(10))
                                  .Select(_ => AllTodoItems.Count != 0 && AllTodoItems.All(x => x.Completed.Value))
                                  .ToReadOnlyReactivePropertySlim()
                                  .AddTo(_disposables);
        }