コード例 #1
0
        public MainVM()
        {
            var bobbyJoe  = new Person("Bobby Joe", new[] { new Pet("Fluffy") });
            var bob       = new Person("Bob", new[] { bobbyJoe });
            var littleJoe = new Person("Little Joe");
            var joe       = new Person("Joe", new[] { littleJoe });

            Family = new ReactiveList <TreeItem> {
                bob, joe
            };

            _addPerson = ReactiveCommand.Create();
            _addPerson.Subscribe(_ =>
            {
                if (SelectedItem == null)
                {
                    return;
                }
                var p = new Person(NewName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _addPet = ReactiveCommand.Create();
            _addPet.Subscribe(_ =>
            {
                if (SelectedItem == null)
                {
                    return;
                }
                var p = new Pet(PetName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _collapse = ReactiveCommand.Create();
            _collapse.Subscribe(_ =>
            {
                SelectedItem?.CollapsePath();
            });
        }