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);
                    }
                });
        }
예제 #2
0
 private TestViewModel CreateTestViewModelFromTestModel(TestModel m)
 {
     var vm = new TestViewModel
     {
         Id = m.Id,
         Name = m.Name,
         OtherValue = "",
         OriginalModel = m
     };
     vm.DoStuffWithThisCommand.Subscribe(x => DoStuff(x as TestViewModel));
     return vm;
 }
예제 #3
0
 private void DoStuff(TestViewModel vm)
 {
     TestModels.Remove(vm.OriginalModel);
 }