Ejemplo n.º 1
0
        bool ClearElementToUniqueIdResetPool(UIElement element, VirtualizationInfo virtInfo)
        {
            if (m_isDataSourceStableResetPending)
            {
                m_resetPool.Add(element);
                virtInfo.MoveOwnershipToUniqueIdResetPoolFromLayout();
            }

            return(m_isDataSourceStableResetPending);
        }
Ejemplo n.º 2
0
        void UpdateElementIndex(UIElement element, VirtualizationInfo virtInfo, int index)
        {
            var oldIndex = virtInfo.Index;

            if (oldIndex != index)
            {
                virtInfo.UpdateIndex(index);
                m_owner.OnElementIndexChanged(element, oldIndex, index);
            }
        }
Ejemplo n.º 3
0
        public int GetElementIndex(VirtualizationInfo virtInfo)
        {
            if (virtInfo == null)
            {
                //Element is not a child of this ItemsRepeater.
                return(-1);
            }

            return(virtInfo.IsRealized || virtInfo.IsInUniqueIdResetPool ? virtInfo.Index : -1);
        }
Ejemplo n.º 4
0
        public void PhaseElement(UIElement element, VirtualizationInfo virtInfo)
        {
            var  dataTemplateComponent = virtInfo.DataTemplateComponent;
            var  nextPhase             = virtInfo.Phase;
            bool shouldPhase           = false;

            if (nextPhase > 0)
            {
                if (dataTemplateComponent != null)
                {
                    // Perf optimization: RecyclingElementFactory sets up the virtualization info so we don't need to update it here.
                    shouldPhase = true;
                }
                else
                {
                    throw new InvalidOperationException("Phase was set on virtualization info, but dataTemplateComponent was not.");
                }
            }
            else if (nextPhase == VirtualizationInfo.PhaseNotSpecified)
            {
                // If virtInfo.Phase is not specified, virtInfo.DataTemplateComponent cannot be valid.
                global::System.Diagnostics.Debug.Assert(dataTemplateComponent == null);
                // ItemsRepeater might be using a custom view generator in which case, virtInfo would not be bootstrapped.
                // In this case, fallback to querying for the data template component and setup virtualization info now.
                dataTemplateComponent = XamlBindingHelper.GetDataTemplateComponent(element);
                if (dataTemplateComponent != null)
                {
                    // Clear out old data.
                    dataTemplateComponent.Recycle();

                    nextPhase = VirtualizationInfo.PhaseReachedEnd;
                    var index = virtInfo.Index;
                    var data  = m_owner.ItemsSourceView.GetAt(index);
                    // Run Phase 0
                    dataTemplateComponent.ProcessBindings(data, index, 0 /* currentPhase */, out nextPhase);

                    // Update phase on virtInfo. Set data and templateComponent only if x:Phase was used.
                    virtInfo.UpdatePhasingInfo(nextPhase, nextPhase > 0 ? data : null, nextPhase > 0 ? dataTemplateComponent : null);
                    shouldPhase = nextPhase > 0;
                }
            }

            if (shouldPhase)
            {
                // Insert at the top since we remove from bottom during DoPhasedWorkCallback. This keeps the ordering of items
                // the same as the order in which items are realized.
                m_pendingElements.Insert(0, new ElementInfo(element, virtInfo));
                RegisterForCallback();
            }
        }
Ejemplo n.º 5
0
        public void StopPhasing(UIElement element, VirtualizationInfo virtInfo)
        {
            // We need to remove the element from the pending elements list. We cannot just change the phase to -1
            // since it will get updated when the element gets recycled.
            if (virtInfo.DataTemplateComponent != null)
            {
                var it = m_pendingElements.FindIndex(info => info.Element == element);
                if (it != -1)
                {
                    m_pendingElements.RemoveAt(it);
                }
            }

            // Clean Phasing information for this item.
            virtInfo.UpdatePhasingInfo(VirtualizationInfo.PhaseNotSpecified, null /* data */, null /* dataTemplateComponent */);
        }
Ejemplo n.º 6
0
        bool ClearElementToPinnedPool(UIElement element, VirtualizationInfo virtInfo, bool isClearedDueToCollectionChange)
        {
            bool moveToPinnedPool =
                !isClearedDueToCollectionChange && virtInfo.IsPinned;

            if (moveToPinnedPool)
            {
#if DEBUG
                for (int i = 0; i < m_pinnedPool.Count; ++i)
                {
                    MUX_ASSERT(m_pinnedPool[i].PinnedElement != element);
                }
#endif
                m_pinnedPool.Add(new PinnedElementInfo(element));
                virtInfo.MoveOwnershipToPinnedPool();
            }

            return(moveToPinnedPool);
        }
Ejemplo n.º 7
0
        bool ClearElementToAnimator(UIElement element, VirtualizationInfo virtInfo)
        {
            bool cleared = m_owner.AnimationManager.ClearElement(element);

            if (cleared)
            {
                int clearedIndex = virtInfo.Index;
                virtInfo.MoveOwnershipToAnimator();
                if (m_lastFocusedElement == element)
                {
                    // Focused element is going away. Remove the tracked last focused element
                    // and pick a reasonable next focus if we can find one within the layout
                    // realized elements.
                    MoveFocusFromClearedIndex(clearedIndex);
                }
            }

            return(cleared);
        }
Ejemplo n.º 8
0
 public PinnedElementInfo(UIElement element)
 {
     m_pinnedElement = element;
     m_virtInfo      = ItemsRepeater.GetVirtualizationInfo(element);
 }
Ejemplo n.º 9
0
 public ElementInfo(UIElement element, VirtualizationInfo virtInfo)
 {
     Element  = element;
     VirtInfo = virtInfo;
 }