///
        protected override string GetNameCore()
        {
            AutomationPeer wrapperPeer = GetWrapperPeer();
            string         name        = null;
            object         item        = Item;

            if (wrapperPeer != null)
            {
                name = wrapperPeer.GetName();
            }
            else if (item != null)
            {
                using (RecyclableWrapper recyclableWrapper = ItemsControlAutomationPeer.GetRecyclableWrapperPeer(item))
                {
                    name = recyclableWrapper.Peer.GetName();
                }
            }

            if (string.IsNullOrEmpty(name) && item != null)
            {
                // For FE we can't use ToString as that provides extraneous information than just the plain text
                FrameworkElement fe = item as FrameworkElement;
                if (fe != null)
                {
                    name = fe.GetPlainText();
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = item.ToString();
                }
            }

            return(name);
        }
Exemple #2
0
        /// <summary>Gets the text label of the <see cref="T:System.Windows.UIElement" /> that corresponds to the data item in the <see cref="P:System.Windows.Controls.ItemsControl.Items" /> collection that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemAutomationPeer" />. </summary>
        /// <returns>The text label.</returns>
        // Token: 0x0600271E RID: 10014 RVA: 0x000B8FD4 File Offset: 0x000B71D4
        protected override string GetNameCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();
            string         text        = null;
            object         item        = this.Item;

            if (wrapperPeer != null)
            {
                text = wrapperPeer.GetName();
            }
            else if (item != null)
            {
                using (RecyclableWrapper recyclableWrapperPeer = this.ItemsControlAutomationPeer.GetRecyclableWrapperPeer(item))
                {
                    text = recyclableWrapperPeer.Peer.GetName();
                }
            }
            if (string.IsNullOrEmpty(text) && item != null)
            {
                FrameworkElement frameworkElement = item as FrameworkElement;
                if (frameworkElement != null)
                {
                    text = frameworkElement.GetPlainText();
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = item.ToString();
                }
            }
            return(text);
        }
Exemple #3
0
        internal RecyclableWrapper GetRecyclableWrapperPeer(object item)
        {
            ItemsControl itemsControl = (ItemsControl)Owner;

            if (_recyclableWrapperCache == null)
            {
                _recyclableWrapperCache = new RecyclableWrapper(itemsControl, item);
            }
            else
            {
                _recyclableWrapperCache.LinkItem(item);
            }

            return(_recyclableWrapperCache);
        }
Exemple #4
0
        ///
        protected override string GetAutomationIdCore()
        {
            AutomationPeer wrapperPeer = GetWrapperPeer();
            string         id          = null;

            if (wrapperPeer != null)
            {
                id = wrapperPeer.GetAutomationId();
            }
            else if (_item != null)
            {
                using (RecyclableWrapper recyclableWrapper = ItemsControlAutomationPeer.GetRecyclableWrapperPeer(_item))
                {
                    id = recyclableWrapper.Peer.GetAutomationId();
                }
            }

            return(id);
        }
Exemple #5
0
        /// <summary>Gets the string that uniquely identifies the <see cref="T:System.Windows.UIElement" /> that corresponds to the data item in the <see cref="P:System.Windows.Controls.ItemsControl.Items" /> collection that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemAutomationPeer" />. </summary>
        /// <returns>A string that contains the UI Automation identifier.</returns>
        // Token: 0x0600271D RID: 10013 RVA: 0x000B8F70 File Offset: 0x000B7170
        protected override string GetAutomationIdCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();
            string         result      = null;
            object         item;

            if (wrapperPeer != null)
            {
                result = wrapperPeer.GetAutomationId();
            }
            else if ((item = this.Item) != null)
            {
                using (RecyclableWrapper recyclableWrapperPeer = this.ItemsControlAutomationPeer.GetRecyclableWrapperPeer(item))
                {
                    result = recyclableWrapperPeer.Peer.GetAutomationId();
                }
            }
            return(result);
        }