Ejemplo n.º 1
0
        /// <summary>
        /// Handles changes on the <see cref="NodeSortDescriptionsProperty"/> dependency property. As
        /// WPF internally uses the dependency property system and bypasses the
        /// <see cref="NodeSortDescriptions"/> property wrapper, updates should be handled here.
        /// </summary>
        /// <param name="d">The currently processed owner of the property.</param>
        /// <param name="e">Provides information about the updated property.</param>
        private static void NodeSortDescriptionsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //don't do anything if the control is being created
            TreeViewBase <T> owner = (TreeViewBase <T>)d;

            if (!owner.IsInitialized || owner.Tree == null)
            {
                return;
            }

            //set sort parameters on tree (root == null) or root node
            owner.ApplySorting(owner.RootNode, null);

            //iterate over all nodes and apply sorting
            foreach (TreeViewItem item in owner.RecursiveNodeList)
            {
                owner.ApplySorting(item, (T)item.Header);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles changes on the <see cref="RootNodeProperty"/> dependency property. As
        /// WPF internally uses the dependency property system and bypasses the
        /// <see cref="RootNode"/> property wrapper, updates should be handled here.
        /// </summary>
        /// <param name="d">The currently processed owner of the property.</param>
        /// <param name="e">Provides information about the updated property.</param>
        private static void RootNodePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //just recreate the tree - this takes care of everything
            TreeViewBase <T> owner    = (TreeViewBase <T>)d;
            TreeViewItem     newValue = (TreeViewItem)e.NewValue;

            //don't do anything if the control is being created
            if (!owner.IsInitialized)
            {
                return;
            }

            owner.Refresh(owner.GetTreeLayout());

            //apply sorting on root or tree (if the new value is null)
            owner.ApplySorting(newValue, null);
        }