Ejemplo n.º 1
0
        public NodeCategoryViewModel(string name, IEnumerable <NodeSearchElementViewModel> entries, IEnumerable <NodeCategoryViewModel> subs)
        {
            ClickedCommand = new DelegateCommand(Expand);

            Name          = name;
            this.entries  = new ObservableCollection <NodeSearchElementViewModel>(entries.OrderBy(x => x.Name));
            subCategories = new ObservableCollection <NodeCategoryViewModel>(subs.OrderBy(x => x.Name));

            foreach (var category in SubCategories)
            {
                category.PropertyChanged += CategoryOnPropertyChanged;
            }

            Entries.CollectionChanged       += OnCollectionChanged;
            SubCategories.CollectionChanged += OnCollectionChanged;
            SubCategories.CollectionChanged += SubCategoriesOnCollectionChanged;

            items = new ObservableCollection <ISearchEntryViewModel>(
                SubCategories.Cast <ISearchEntryViewModel>().Concat(Entries));

            Items.CollectionChanged += ItemsOnCollectionChanged;

            foreach (var item in Items)
            {
                item.PropertyChanged += ItemOnPropertyChanged;
            }

            Visibility = true;
            IsExpanded = false;
        }