Beispiel #1
0
        protected override IList <AutomationPeer> GetChildrenCore()
        {
            Controls.TreeView owner = OwnerTreeView;

            ItemCollection items = owner.Items;

            if (items.Count <= 0)
            {
                return(null);
            }

            List <AutomationPeer> peers = new List <AutomationPeer>(items.Count);

            for (int i = 0; i < items.Count; i++)
            {
                Controls.TreeViewItem element = owner.ItemContainerGenerator.ContainerFromIndex(i) as Controls.TreeViewItem;
                if (element != null)
                {
                    peers.Add(
                        FrameworkElementAutomationPeer.FromElement(element) ??
                        FrameworkElementAutomationPeer.CreatePeerForElement(element));
                }
            }

            return(peers);
        }
 /// <summary>
 /// Adds the current element to the collection of selected items.
 /// </summary>
 /// <remarks>
 /// This API supports the .NET Framework infrastructure and is not
 /// intended to be used directly from your code.
 /// </remarks>
 void ISelectionItemProvider.AddToSelection()
 {
     Controls.TreeViewItem owner  = OwnerTreeViewItem;
     Controls.TreeView     parent = owner.ParentTreeView;
     if (parent == null || (parent.SelectedItem != null && parent.SelectedContainer != Owner))
     {
         throw new InvalidOperationException(/*Controls.Properties.Resources.Automation_OperationCannotBePerformed*/);
     }
     owner.IsSelected = true;
 }
        /// <summary>
        /// Scrolls the content area of a container object in order to display
        /// the control within the visible region (viewport) of the container.
        /// </summary>
        /// <remarks>
        /// This API supports the .NET Framework infrastructure and is not
        /// intended to be used directly from your code.
        /// </remarks>
        void IScrollItemProvider.ScrollIntoView()
        {
            // Note: WPF just calls BringIntoView on the current TreeViewItem.
            // This actually raises an event that can be handled by the
            // its containers.  Silverlight doesn't support this, so we will
            // approximate by moving scrolling the TreeView's ScrollHost to the
            // item.

            // Get the parent TreeView
            Controls.TreeViewItem owner  = OwnerTreeViewItem;
            Controls.TreeView     parent = owner.ParentTreeView;
            if (parent == null)
            {
                return;
            }

            // Scroll the item into view
            parent.ItemsControlHelper.ScrollIntoView(owner);
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:System.Windows.Automation.Peers.TreeViewAutomationPeer" />
 /// class.
 /// </summary>
 /// <param name="owner">
 /// The <see cref="T:System.Windows.Controls.TreeView" /> to associate
 /// with the
 /// <see cref="T:System.Windows.Automation.Peers.TreeViewAutomationPeer" />.
 /// </param>
 public TreeViewAutomationPeer(Controls.TreeView owner)
     : base(owner)
 {
 }