///
        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);
        }
Esempio n. 2
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);
        }