private void MeasureFocusedItem(int focusedIndex)
            {
                if (focusedIndex < 0 || focusedIndex >= SourceCount)
                {
                    return;
                }

                if (focusedIndex >= FirstIndex && focusedIndex <= LastIndex)
                {
                    return;
                }

                var focusedItem = Realize(focusedIndex);

                if (focusedItem == null)
                {
                    return;
                }

                if (focusedIndex < FirstIndex)
                {
                    InsertItem(0, focusedItem);
                    Layout.MeasureChild(focusedItem, OrientedConstraint.Size);

                    OrientedLeadingSize = OrientedLeadingSize.StackSize(focusedItem.DesiredSize);
                }
                else
                {
                    AddItem(focusedItem);
                    Layout.MeasureChild(focusedItem, OrientedConstraint.Size);

                    OrientedTrailingSize = OrientedTrailingSize.StackSize(focusedItem.DesiredSize);
                }
            }
            private void MeasureLeading()
            {
                FirstIndex        = (OffsetElementIndex - Layout.Panel.LeadingTrailingLimit).Clamp(0, SourceCount);
                FirstVisibleIndex = OffsetElementIndex.Clamp(0, SourceCount);

                var constraint = OrientedConstraint.Size;
                var index      = FirstIndex;

                while (index < FirstVisibleIndex && index < SourceCount)
                {
                    var element = Realize(index);

                    if (element == null)
                    {
                        index++;

                        continue;
                    }

                    AddItem(element);
                    Layout.MeasureChild(element, constraint);

                    OrientedLeadingSize = OrientedLeadingSize.StackSize(element.DesiredSize);
                    LeadingCacheCount++;

                    index++;
                }
            }
            private void MeasureVisible()
            {
                var constraint    = OrientedConstraint.Size;
                var index         = FirstVisibleIndex;
                var realizedIndex = index;

                while (OrientedAvailable.Direct > OrientedResult.Direct && index < SourceCount)
                {
                    var element = Realize(index);

                    if (element == null)
                    {
                        index++;

                        continue;
                    }

                    realizedIndex = index;

                    AddItem(element);
                    Layout.MeasureChild(element, constraint);

                    OrientedResult = OrientedResult.StackSize(element.DesiredSize);

                    index++;
                }

                LastVisibleIndex = realizedIndex;
                LastIndex        = realizedIndex;

                // Offset error. Move leading cache
                while (OrientedAvailable.Direct > OrientedResult.Direct && FirstVisibleIndex > FirstIndex && FirstVisibleIndex > 0)
                {
                    var element      = Layout.UIElementInserter[FirstVisibleIndex - FirstIndex - 1];
                    var orientedSize = element.DesiredSize.AsOriented(Orientation);
                    var direct       = OrientedResult.Direct + orientedSize.Direct;

                    if (direct > OrientedAvailable.Direct)
                    {
                        return;
                    }

                    OrientedResult      = OrientedResult.ChangeDirect(direct);
                    OrientedLeadingSize = OrientedLeadingSize.ChangeDirect(OrientedLeadingSize.Direct - orientedSize.Direct);

                    FirstVisibleIndex--;
                    LeadingCacheCount--;
                }

                // Offset error. Measure beyond offset
                if (OrientedAvailable.Direct > OrientedResult.Direct && FirstVisibleIndex > 0)
                {
                    Debug.Assert(LeadingCacheCount == 0);

                    while (OrientedAvailable.Direct > OrientedResult.Direct && FirstVisibleIndex > 0)
                    {
                        var element = Realize(FirstVisibleIndex - 1);

                        if (element == null)
                        {
                            FirstVisibleIndex--;

                            continue;
                        }

                        InsertItem(0, element);
                        Layout.MeasureChild(element, constraint);

                        OrientedResult = OrientedResult.StackSize(element.DesiredSize);

                        FirstVisibleIndex--;
                    }

                    FirstIndex = FirstVisibleIndex;

                    // Remeasure leading cache
                    while (LeadingCacheCount < Layout.Panel.LeadingTrailingLimit && FirstIndex > 0)
                    {
                        var element = Realize(FirstIndex - 1);

                        if (element == null)
                        {
                            FirstIndex--;

                            continue;
                        }

                        InsertItem(0, element);
                        Layout.MeasureChild(element, constraint);

                        OrientedLeadingSize = OrientedLeadingSize.StackSize(element.DesiredSize);

                        FirstIndex--;
                        LeadingCacheCount++;
                    }
                }
            }