internal override bool PositionTopRealizedItem(ref double visibleItemsTop) { RadVirtualizingDataControlItem firstRealizedItem = this.owner.firstItemCache; WrapRow firstWrapRow = null; int wrapRowsCount = this.wrapRows.Count; if (wrapRowsCount > 0) { firstWrapRow = this.wrapRows[0]; } bool isEnoughSpaceForItemInRow = this.CheckEnoughSpaceForItemInRow(firstWrapRow, firstRealizedItem, false); if (firstWrapRow == null || !isEnoughSpaceForItemInRow) { if (!isEnoughSpaceForItemInRow) { visibleItemsTop -= firstWrapRow.rowLength; this.OnRowFilled(firstWrapRow, false); if (!this.CanRealizeTop(visibleItemsTop)) { return(false); } } firstWrapRow = this.InsertWrapRowAt(0); firstWrapRow.lastItem = firstRealizedItem; firstWrapRow.rowLength = this.GetItemLength(firstRealizedItem); firstWrapRow.rowOffset = firstWrapRow.next != null ? firstWrapRow.next.rowOffset - firstWrapRow.rowLength : 0; } double currentRowLength = firstWrapRow.rowLength; double difference = 0; switch (this.orientationCache) { case Orientation.Horizontal: difference = firstRealizedItem.height - currentRowLength; if (currentRowLength < firstRealizedItem.height) { firstWrapRow.rowLength = firstRealizedItem.height; visibleItemsTop -= difference; firstWrapRow.rowOffset -= difference; } firstRealizedItem.SetVerticalOffset(firstWrapRow.rowOffset); if (firstWrapRow.firstItem == null) { firstRealizedItem.SetHorizontalOffset(this.owner.availableWidth - firstRealizedItem.width); } else { firstRealizedItem.SetHorizontalOffset(firstWrapRow.firstItem.horizontalOffsetCache - firstRealizedItem.width); if (difference != 0) { this.SynchItemOffsetInRow(firstWrapRow); } } break; case Orientation.Vertical: difference = firstRealizedItem.width - currentRowLength; if (currentRowLength < firstRealizedItem.width) { firstWrapRow.rowLength = firstRealizedItem.width; visibleItemsTop -= difference; firstWrapRow.rowOffset -= difference; } firstRealizedItem.SetHorizontalOffset(firstWrapRow.rowOffset); if (firstWrapRow.firstItem == null) { firstRealizedItem.SetVerticalOffset(this.owner.availableHeight - firstRealizedItem.height); } else { firstRealizedItem.SetVerticalOffset(firstWrapRow.firstItem.verticalOffsetCache - firstRealizedItem.height); if (difference != 0) { this.SynchItemOffsetInRow(firstWrapRow); } } break; } firstWrapRow.firstItem = firstRealizedItem; firstRealizedItem.wrapRow = firstWrapRow; if (this.owner.IsFirstItemFirstInListSource()) { this.OnRowFilled(firstWrapRow, false); } return(true); }
internal override void OnContainerSizeChanged(RadVirtualizingDataControlItem container, Size newSize, Size oldSize) { base.OnContainerSizeChanged(container, newSize, oldSize); if (!this.topRealized.Contains(container)) { RadVirtualizingDataControlItem pivotContainer = container.next; int containersToSkip = 0; if (pivotContainer != null) { containersToSkip = Math.Max(this.stackCount - this.owner.realizedItems.IndexOf(pivotContainer), 0); } while (pivotContainer != null) { if (containersToSkip > 0) { containersToSkip--; continue; } this.slotsRepository.Remove(pivotContainer.associatedDataItem.GetHashCode()); pivotContainer = pivotContainer.next; } this.ReorderViewportOnItemsChanged(); } else { double newOffset = 0; double offsetDelta = 0; switch (this.orientationCache) { case Orientation.Horizontal: offsetDelta = newSize.Height - oldSize.Height; newOffset = container.verticalOffsetCache - offsetDelta; container.SetVerticalOffset(newOffset); double horizontalOffset = container.horizontalOffsetCache; while (container.previous != null) { container = container.previous; if (container.horizontalOffsetCache == horizontalOffset) { container.SetVerticalOffset(container.verticalOffsetCache - offsetDelta); } } break; case Orientation.Vertical: offsetDelta = newSize.Width - oldSize.Width; newOffset = container.horizontalOffsetCache - offsetDelta; container.SetHorizontalOffset(newOffset); double verticalOffset = container.verticalOffsetCache; while (container.previous != null) { container = container.previous; if (container.verticalOffsetCache == verticalOffset) { container.SetHorizontalOffset(container.horizontalOffsetCache - offsetDelta); } } break; } } // Extend the length with the new diff, although the extension could be less var prevLength = this.Orientation == Windows.UI.Xaml.Controls.Orientation.Horizontal ? oldSize.Height : oldSize.Width; var sizeChange = this.GetItemLength(container) - prevLength; this.CorrectScrollableContentSize(sizeChange); this.EnsureCorrectLayout(); this.CheckBottomScrollableBounds(); }
internal override bool PositionBottomRealizedItem(RadVirtualizingDataControlItem item, ref double visibleItemsBottom) { RadVirtualizingDataControlItem realizedItem = item; double itemLength = this.GetItemLength(realizedItem); WrapRow lastWrapRow = null; int wrapRowsCount = this.wrapRows.Count; if (wrapRowsCount > 0) { lastWrapRow = this.wrapRows[wrapRowsCount - 1]; } bool isEnoughSpaceForItemInRow = true; if (lastWrapRow != null) { isEnoughSpaceForItemInRow = this.CheckEnoughSpaceForItemInRow(lastWrapRow, realizedItem, true); } if (lastWrapRow == null || !isEnoughSpaceForItemInRow) { if (!isEnoughSpaceForItemInRow) { visibleItemsBottom += lastWrapRow.rowLength; this.OnRowFilled(lastWrapRow, true); if (!this.CanRealizeBottom(visibleItemsBottom)) { return(false); } } lastWrapRow = this.InsertWrapRowAt(wrapRowsCount); lastWrapRow.firstItem = realizedItem; if (lastWrapRow.previous == null) { double defaultPosition = 0; if (this.owner.scrollScheduled) { defaultPosition = this.ScrollOffset; } lastWrapRow.rowOffset = this.averageItemLength > 0 ? item.AssociatedDataItem.Index / this.averageItemCountPerRow * this.averageItemLength : defaultPosition; } else { lastWrapRow.rowOffset = lastWrapRow.previous.rowOffset + lastWrapRow.previous.rowLength; } lastWrapRow.rowLength = itemLength; } double currentRowLength = lastWrapRow.rowLength; switch (this.orientationCache) { case Orientation.Horizontal: if (currentRowLength < realizedItem.height) { lastWrapRow.rowLength = realizedItem.height; visibleItemsBottom += realizedItem.height - currentRowLength; } realizedItem.SetVerticalOffset(lastWrapRow.rowOffset); if (lastWrapRow.lastItem == null) { realizedItem.SetHorizontalOffset(0); } else { realizedItem.SetHorizontalOffset(lastWrapRow.lastItem.horizontalOffsetCache + lastWrapRow.lastItem.width); } break; case Orientation.Vertical: if (currentRowLength < realizedItem.width) { lastWrapRow.rowLength = realizedItem.width; visibleItemsBottom += realizedItem.width - currentRowLength; } realizedItem.SetHorizontalOffset(lastWrapRow.rowOffset); if (lastWrapRow.lastItem == null) { realizedItem.SetVerticalOffset(0); } else { realizedItem.SetVerticalOffset(lastWrapRow.lastItem.verticalOffsetCache + lastWrapRow.lastItem.height); } break; } lastWrapRow.lastItem = realizedItem; realizedItem.wrapRow = lastWrapRow; if (this.owner.IsLastItemLastInListSource()) { this.OnRowFilled(lastWrapRow, true); } return(true); }