public MainWindowModel() { _testDataSource = new TestDataSource(); TestModels = new ReactiveList <TestModel>(); TestViewModels = TestModels.CreateDerivedCollection(m => { var vm = new TestViewModel { Id = m.Id, Name = m.Name, OtherValue = "", OriginalModel = m }; vm.DoStuffWithThisCommand.Subscribe(x => DoStuff(x as TestViewModel)); return(vm); }, m => true, (m, vm) => 0); SetUpDataCommand = ReactiveCommand.CreateAsyncTask(_ => _testDataSource.GetTests()); SetUpDataCommand.Subscribe(results => { using (SuppressChangeNotifications()) { TestModels.Clear(); foreach (var model in results) { TestModels.Add(model); } } }); }
public MainWindowModel() { _testDataSource = new TestDataSource(); TestModels = new ReactiveList <TestModel>(); //TODO: Add code that declares a derviced collection which uses `CreateTestViewModelFromTestModel` // as it's conversion, uses `true` as it's filter and 0 as the ordering function //TODO: Move the `CreateTestViewModelFromTestModel` function into a lambda SetUpDataCommand = ReactiveCommand.CreateAsyncTask(_ => _testDataSource.GetTests()); SetUpDataCommand.Subscribe(results => { using (SuppressChangeNotifications()) { TestModels.Clear(); foreach (var model in results) { TestModels.Add(model); } } }); }