Exemple #1
0
        private void HandleBringIntoView(RequestBringIntoViewEventArgs e)
        {
            TreeViewItem parent = ParentTreeViewItem;

            while (parent != null)
            {
                if (!parent.IsExpanded)
                {
                    parent.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox);
                }

                parent = parent.ParentTreeViewItem;
            }

            // See FrameworkElement.BringIntoView() comments
            //dmitryt, bug 1126518. On new/updated elements RenderSize isn't yet computed
            //so we need to postpone the rect computation until layout is done.
            //this is accomplished by passing Empty rect here and then asking for RenderSize
            //in IScrollInfo when it actually executes an async MakeVisible command.
            if (e.TargetRect.IsEmpty)
            {
                FrameworkElement header = HeaderElement;
                if (header != null)
                {
                    e.Handled = true;
                    header.BringIntoView();
                }
                else
                {
                    // Header is not generated yet. Could happen if BringIntoView is called on container before layout. Try later.
                    Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(BringItemIntoView), null);
                }
            }
        }
Exemple #2
0
        private void HandleBringIntoView(RequestBringIntoViewEventArgs e)
        {
            TreeViewItem parent = ParentTreeViewItem;

            while (parent != null)
            {
                if (!parent.IsExpanded)
                {
                    parent.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox);
                }

                parent = parent.ParentTreeViewItem;
            }

            // See FrameworkElement.BringIntoView() comments
            //dmitryt,



            if (e.TargetRect.IsEmpty)
            {
                FrameworkElement header = HeaderElement;
                if (header != null)
                {
                    e.Handled = true;
                    header.BringIntoView();
                }
                else
                {
                    // Header is not generated yet. Could happen if BringIntoView is called on container before layout. Try later.
                    Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(BringItemIntoView), null);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Recursively & syncronously expand all the nodes in this subtree.
        /// </summary>
        private static void ExpandRecursive(TreeViewItem item)
        {
            if (item == null)
            {
                return;
            }

            // Expand the current item
            if (!item.IsExpanded)
            {
                item.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox);
            }

            // ApplyTemplate in order to generate the ItemsPresenter and the ItemsPanel. Note that in the
            // virtualizing case even if the item is marked expanded we still need to do this step in order to
            // regenerate the visuals because they may have been virtualized away.

            item.ApplyTemplate();
            ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName(ItemsHostPartName, item);

            if (itemsPresenter != null)
            {
                itemsPresenter.ApplyTemplate();
            }
            else
            {
                item.UpdateLayout();
            }

            VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel;

            item.ItemsHost.EnsureGenerator();

            for (int i = 0, count = item.Items.Count; i < count; i++)
            {
                TreeViewItem subitem;
                if (virtualizingPanel != null)
                {
                    // We need to bring the item into view so that the container will be generated.
                    virtualizingPanel.BringIndexIntoView(i);

                    subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i);
                }
                else
                {
                    subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i);

                    // We dont actually need to bring this into view, but we'll do it
                    // anyways to maintain the same behavior as with a virtualizing panel.
                    subitem.BringIntoView();
                }

                if (subitem != null)
                {
                    ExpandRecursive(subitem);
                }
            }
        }
        // Token: 0x06005934 RID: 22836 RVA: 0x0018A638 File Offset: 0x00188838
        private static void ExpandRecursive(TreeViewItem item)
        {
            if (item == null)
            {
                return;
            }
            if (!item.IsExpanded)
            {
                item.SetCurrentValueInternal(TreeViewItem.IsExpandedProperty, BooleanBoxes.TrueBox);
            }
            item.ApplyTemplate();
            ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName("ItemsHost", item);

            if (itemsPresenter != null)
            {
                itemsPresenter.ApplyTemplate();
            }
            else
            {
                item.UpdateLayout();
            }
            VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel;

            item.ItemsHost.EnsureGenerator();
            int i     = 0;
            int count = item.Items.Count;

            while (i < count)
            {
                TreeViewItem treeViewItem;
                if (virtualizingPanel != null)
                {
                    virtualizingPanel.BringIndexIntoView(i);
                    treeViewItem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i);
                }
                else
                {
                    treeViewItem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i);
                    treeViewItem.BringIntoView();
                }
                if (treeViewItem != null)
                {
                    TreeViewItem.ExpandRecursive(treeViewItem);
                }
                i++;
            }
        }
 // Token: 0x06005928 RID: 22824 RVA: 0x0018A374 File Offset: 0x00188574
 private void HandleBringIntoView(RequestBringIntoViewEventArgs e)
 {
     for (TreeViewItem parentTreeViewItem = this.ParentTreeViewItem; parentTreeViewItem != null; parentTreeViewItem = parentTreeViewItem.ParentTreeViewItem)
     {
         if (!parentTreeViewItem.IsExpanded)
         {
             parentTreeViewItem.SetCurrentValueInternal(TreeViewItem.IsExpandedProperty, BooleanBoxes.TrueBox);
         }
     }
     if (e.TargetRect.IsEmpty)
     {
         FrameworkElement headerElement = this.HeaderElement;
         if (headerElement != null)
         {
             e.Handled = true;
             headerElement.BringIntoView();
             return;
         }
         base.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(this.BringItemIntoView), null);
     }
 }
Exemple #6
0
        /// <summary>
        /// Recursively & syncronously expand all the nodes in this subtree. 
        /// </summary> 
        private static void ExpandRecursive(TreeViewItem item)
        { 
            if (item == null)
            {
                return;
            } 

            // Expand the current item 
            if (!item.IsExpanded) 
            {
                item.SetCurrentValueInternal(IsExpandedProperty, BooleanBoxes.TrueBox); 
            }

            // ApplyTemplate in order to generate the ItemsPresenter and the ItemsPanel. Note that in the
            // virtualizing case even if the item is marked expanded we still need to do this step in order to 
            // regenerate the visuals because they may have been virtualized away.
 
            item.ApplyTemplate(); 
            ItemsPresenter itemsPresenter = (ItemsPresenter)item.Template.FindName("ItemsHost", item);
            if (itemsPresenter != null) 
            {
                itemsPresenter.ApplyTemplate();
            }
            else 
            {
                item.UpdateLayout(); 
            } 

            VirtualizingPanel virtualizingPanel = item.ItemsHost as VirtualizingPanel; 
            item.ItemsHost.EnsureGenerator();

            for (int i = 0, count = item.Items.Count; i < count; i++)
            { 
                TreeViewItem subitem;
                if (virtualizingPanel != null) 
                { 
                    // We need to bring the item into view so that the container will be generated.
                    virtualizingPanel.BringIndexIntoView(i); 

                    subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i);
                }
                else 
                {
                    subitem = (TreeViewItem)item.ItemContainerGenerator.ContainerFromIndex(i); 
 
                    // We dont actually need to bring this into view, but we'll do it
                    // anyways to maintain the same behavior as with a virtualizing panel. 
                    subitem.BringIntoView();
                }

                if (subitem != null) 
                {
                    ExpandRecursive(subitem); 
                } 
            }
        }