Example #1
0
        public UIElement GetElement(int index, bool forceCreate, bool suppressAutoRecycle)
        {
            UIElement element = forceCreate ? null : GetElementIfAlreadyHeldByLayout(index);

            if (element == null)
            {
                // check if this is the anchor made through repeater in preparation
                // for a bring into view.
                var madeAnchor = m_owner.MadeAnchor;
                if (madeAnchor != null)
                {
                    var anchorVirtInfo = ItemsRepeater.TryGetVirtualizationInfo(madeAnchor);
                    if (anchorVirtInfo.Index == index)
                    {
                        element = madeAnchor;
                    }
                }
            }

            if (element == null)
            {
                element = GetElementFromUniqueIdResetPool(index);
            }

            if (element == null)
            {
                element = GetElementFromPinnedElements(index);
            }

            if (element == null)
            {
                element = GetElementFromElementFactory(index);
            }

            var virtInfo = ItemsRepeater.TryGetVirtualizationInfo(element);

            if (suppressAutoRecycle)
            {
                virtInfo.AutoRecycleCandidate = false;
                REPEATER_TRACE_INFO("%* GetElement: %d Not AutoRecycleCandidate: \n", m_owner.Indent(), virtInfo.Index);
            }
            else
            {
                virtInfo.AutoRecycleCandidate = true;
                virtInfo.KeepAlive            = true;
                REPEATER_TRACE_INFO("%* GetElement: %d AutoRecycleCandidate: \n", m_owner.Indent(), virtInfo.Index);
            }

            return(element);
        }