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 = new ReactiveCommand();
            SetUpDataCommand.RegisterAsyncTask(_ => _testDataSource.GetTests())
                .Subscribe(results =>
                {
                    using (SuppressChangeNotifications())
                    {
                        TestModels.Clear();
                        foreach (var model in results)
                            TestModels.Add(model);
                    }
                });
        }
 private void DoStuff(TestViewModel vm)
 {
     TestModels.Remove(vm.OriginalModel);
 }
Пример #3
0
 private void DoStuff(TestViewModel vm)
 {
     TestModels.Remove(vm.OriginalModel);
 }