// Token: 0x060058F7 RID: 22775 RVA: 0x00189CAC File Offset: 0x00187EAC
        private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TreeViewItem treeViewItem   = (TreeViewItem)d;
            bool         flag           = (bool)e.NewValue;
            TreeView     parentTreeView = treeViewItem.ParentTreeView;

            if (parentTreeView != null && !flag)
            {
                parentTreeView.HandleSelectionAndCollapsed(treeViewItem);
            }
            ItemsPresenter itemsHostPresenter = treeViewItem.ItemsHostPresenter;

            if (itemsHostPresenter != null)
            {
                treeViewItem.InvalidateMeasure();
                Helper.InvalidateMeasureOnPath(itemsHostPresenter, treeViewItem, false);
            }
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = UIElementAutomationPeer.FromElement(treeViewItem) as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                treeViewItemAutomationPeer.RaiseExpandCollapseAutomationEvent((bool)e.OldValue, flag);
            }
            if (flag)
            {
                treeViewItem.OnExpanded(new RoutedEventArgs(TreeViewItem.ExpandedEvent, treeViewItem));
            }
            else
            {
                treeViewItem.OnCollapsed(new RoutedEventArgs(TreeViewItem.CollapsedEvent, treeViewItem));
            }
            treeViewItem.UpdateVisualState();
        }
Esempio n. 2
0
        private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TreeViewItem item       = (TreeViewItem)d;
            bool         isExpanded = (bool)e.NewValue;

            TreeView tv = item.ParentTreeView;

            if (tv != null)
            {
                if (!isExpanded)
                {
                    tv.HandleSelectionAndCollapsed(item);
                }
            }

            ItemsPresenter itemsHostPresenter = item.ItemsHostPresenter;

            if (itemsHostPresenter != null)
            {
                // In case a TreeViewItem that wasn't previously expanded is now
                // recycled to represent an entity that is expanded or viceversa, we
                // face a situation where we need to synchronously remeasure the
                // sub tree through the ItemsPresenter leading up to the ItemsHost
                // panel. If we didnt do this the offsets could get skewed.
                item.InvalidateMeasure();
                Helper.InvalidateMeasureOnPath(itemsHostPresenter, item, false /*duringMeasure*/);
            }

            TreeViewItemAutomationPeer peer = UIElementAutomationPeer.FromElement(item) as TreeViewItemAutomationPeer;

            if (peer != null)
            {
                peer.RaiseExpandCollapseAutomationEvent((bool)e.OldValue, isExpanded);
            }

            if (isExpanded)
            {
                item.OnExpanded(new RoutedEventArgs(ExpandedEvent, item));
            }
            else
            {
                item.OnCollapsed(new RoutedEventArgs(CollapsedEvent, item));
            }

            item.UpdateVisualState();
        }