internal void UpdateContainsSelection(bool selected) { // Update the ContainsSelection flag from this item all the way up // through the tree. for (TreeViewItem item = ParentTreeViewItem; item != null; item = item.ParentTreeViewItem) { item.ContainsSelection = selected; } }