Пример #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>
        /// Hides all nodes, controls, or content that are descendants of the
        /// control.
        /// </summary>
        /// <remarks>
        /// This API supports the .NET Framework infrastructure and is not
        /// intended to be used directly from your code.
        /// </remarks>
        void IExpandCollapseProvider.Collapse()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            Controls.TreeViewItem owner = OwnerTreeViewItem;
            if (!owner.HasItems)
            {
                throw new InvalidOperationException(/*Controls.Properties.Resources.Automation_OperationCannotBePerformed*/);
            }

            owner.IsExpanded = false;
        }
Пример #4
0
        /// <summary>
        /// Retrieves a UI automation provider for each child element that is
        /// selected.
        /// </summary>
        /// <returns>An array of UI automation providers.</returns>
        /// <remarks>
        /// This API supports the .NET Framework infrastructure and is not
        /// intended to be used directly from your code.
        /// </remarks>
        IRawElementProviderSimple[] ISelectionProvider.GetSelection()
        {
            IRawElementProviderSimple[] selection = null;

            Controls.TreeViewItem selectedItem = OwnerTreeView.SelectedContainer;
            if (selectedItem != null)
            {
                AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedItem);
                if (peer != null)
                {
                    selection = new IRawElementProviderSimple[] { ProviderFromPeer(peer) };
                }
            }

            return(selection ?? new IRawElementProviderSimple[] { });
        }
        /// <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);
        }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:System.Windows.Automation.Peers.TreeViewItemAutomationPeer" />
 /// class.
 /// </summary>
 /// <param name="owner">
 /// The <see cref="T:System.Windows.Controls.TreeViewItem" /> instance
 /// to associate with this
 /// <see cref="T:System.Windows.Automation.Peers.TreeViewItemAutomationPeer" />.
 /// </param>
 public TreeViewItemAutomationPeer(Controls.TreeViewItem owner)
     : base(owner)
 {
 }