Ejemplo n.º 1
0
        protected virtual void Expand()
        {
            var endState = !IsExpanded;

            foreach (var ele in SubCategories.Where(cat => cat.IsExpanded == true))
            {
                ele.IsExpanded = false;
            }

            //Walk down the tree expanding anything nested one layer deep
            //this can be removed when we have the hierachy implemented properly
            if (Items.Count == 1 && SubCategories.Any())
            {
                var subElement = SubCategories[0];
                while (subElement.Items.Count == 1)
                {
                    subElement.IsExpanded = true;
                    if (subElement.SubCategories.Any())
                    {
                        subElement = subElement.SubCategories[0];
                    }
                    else
                    {
                        break;
                    }
                }

                subElement.IsExpanded = true;
            }

            IsExpanded = endState;
        }
Ejemplo n.º 2
0
 private void CategoryOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     if (propertyChangedEventArgs.PropertyName == "IsExpanded")
     {
         var category = (NodeCategoryViewModel)sender;
         if (category.IsExpanded)
         {
             foreach (var other in SubCategories.Where(other => other != category))
             {
                 other.IsExpanded = false;
             }
         }
     }
 }
Ejemplo n.º 3
0
        public void InsertSubCategory(NodeCategoryViewModel newSubCategory)
        {
            var list = SubCategories.Where(cat => !(cat is ClassesNodeCategoryViewModel));
            var nextLargerItemIndex = FindInsertionPointByName(list, newSubCategory.Name);

            if (nextLargerItemIndex >= 0)
            {
                bool hasClasses = SubCategories.FirstOrDefault() is ClassesNodeCategoryViewModel;
                var  offset     = hasClasses ? 1 : 0;
                SubCategories.Insert(nextLargerItemIndex + offset, newSubCategory);
            }
            else
            {
                SubCategories.Add(newSubCategory);
            }
        }
Ejemplo n.º 4
0
        protected virtual void Expand()
        {
            var endState = !IsExpanded;

            foreach (var ele in SubCategories.Where(cat => cat.IsExpanded))
            {
                ele.IsExpanded = false;
            }

            //Walk down the tree expanding anything nested one layer deep
            //this can be removed when we have the hierachy implemented properly
            if (Items.Count == 1 && SubCategories.Any())
            {
                var subElement = SubCategories[0];
                while (subElement.Items.Count == 1)
                {
                    subElement.IsExpanded = true;
                    if (subElement.SubCategories.Any())
                    {
                        subElement = subElement.SubCategories[0];
                    }
                    else
                    {
                        break;
                    }
                }

                subElement.IsExpanded = true;
            }

            IsExpanded = endState;
            if (TreeViewItems != null)
            {
                //ClassDetails.IsExpanded = IsExpanded;
                TreeViewItems[0].IsExpanded = IsExpanded;
            }

            OnRequestReturnFocusToSearch();
        }