private void OnIsLoopingEnabledChanged() { if (this.owner == null) { return; } this.StopOffsetAnimation(false); if (this.items.Count == 0) { return; } if (!this.isLoopingEnabled) { this.UpdateWheel(0, false); for (int i = 0; i < this.items.Count; i++) { LoopingListItem item = this.items[i]; if (i >= this.logicalCount) { item.SetIsEmpty(true); } } var offset = -this.owner.SelectedIndex * this.itemLength; if (this.isCentered) { offset += this.GetSnapOffsetWhenCentered(); } this.UpdateWheel(offset, false); } else { foreach (LoopingListItem item in this.items) { item.SetIsEmpty(false); } this.InvalidateMeasure(); this.UpdateWheel(this.visualOffset, true); } this.owner.UpdateSelection(this.owner.SelectedIndex, this.owner.GetVisualIndex(this.owner.SelectedIndex), LoopingListSelectionChangeReason.Private); }
private void OnIsLoopingEnabledChanged() { if (this.owner == null) { return; } this.StopOffsetAnimation(false); if (this.items.Count == 0) { return; } if (!this.isLoopingEnabled) { double normalizedOffset = this.visualOffset % (this.logicalCount * this.itemLength); normalizedOffset = normalizedOffset > 0 ? normalizedOffset - (this.itemLength * this.logicalCount) : normalizedOffset; normalizedOffset = this.ClampOffset(normalizedOffset); this.UpdateWheel(0, false); for (int i = 0; i < this.items.Count; i++) { LoopingListItem item = this.items[i]; if (i > this.logicalCount - 1) { item.SetIsEmpty(true); } } this.UpdateWheel(normalizedOffset, false); } else { foreach (LoopingListItem item in this.items) { item.SetIsEmpty(false); } } this.UpdateWheel(this.visualOffset, true); }
private void CreateVisualItems() { int oldCount = this.visualCount; this.UpdateVisualItemCount(); if (this.visualCount == 0 || this.visualCount == oldCount && this.items.Count >= this.visualCount) { return; } if (this.visualCount != oldCount || this.items.Count < this.visualCount) { this.Children.Clear(); this.visualIndexChain.Clear(); this.items.Clear(); } for (int i = 0; i < this.visualCount; i++) { LoopingListItem item = this.CreateVisualItem(); this.Children.Add(item); this.visualIndexChain.Add(i); if (!this.isLoopingEnabled && i > this.logicalCount - 1) { item.SetIsEmpty(true); } } if (this.topLogicalIndex == 0 || this.visualCount != oldCount) { this.UpdateIndexes(this.visualCount != oldCount, false); } else { this.BringIntoView(this.topLogicalIndex, this.visualIndexChain[0]); } }