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; }
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; } } } }
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); } }
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(); }