internal void BringIntoViewCore(BringIntoViewOperation bringIntoViewOperation) { if (bringIntoViewOperation == null) { return; } if (bringIntoViewOperation.ScrollAttempts < BringIntoViewOperation.MaxScrollAttempts) { if (this.IsItemInViewport(bringIntoViewOperation.RequestedItem, false)) { if (bringIntoViewOperation.CompletedAction != null) { bringIntoViewOperation.CompletedAction.Invoke(); } this.UnsubscribeRendering(); } else { this.BringIntoView(bringIntoViewOperation); bringIntoViewOperation.ScrollAttempts++; this.scrollUpdateService.RegisterUpdate(new DelegateUpdate(() => this.BringIntoViewCore(bringIntoViewOperation))); } } else { this.UnsubscribeRendering(); } }
/// <summary> /// Brings the given data item into the viewport and calls the <paramref name="scrollCompletedAction"/> method when the operation is completed. /// </summary> /// <param name="item">The item to show.</param> /// <param name="scrollCompletedAction">Action to be executed when the operation is completed.</param> public virtual void BringIntoView(object item, Action scrollCompletedAction) { if (!this.IsProperlyTemplated) { this.initialVirtualizationItem = this.listSource.FindItem(item); return; } var bringIntoViewOperation = new BringIntoViewOperation(item) { CompletedAction = scrollCompletedAction, LastAverageItemLength = this.virtualizationStrategy.averageItemLength }; this.BringIntoViewCore(bringIntoViewOperation); }
internal virtual void BringIntoView(BringIntoViewOperation bringIntoViewOperation) { // Check whether the item to bring into view is already realized RadVirtualizingDataControlItem foundItem = null; foreach (RadVirtualizingDataControlItem uiItem in this.realizedItems) { if (object.Equals(uiItem.associatedDataItem.Value, bringIntoViewOperation.RequestedItem)) { foundItem = uiItem; break; } } // If the item is not realized, recycle all items and start realizing from the pivot item (the one we should bring into view). if (foundItem == null) { this.initialVirtualizationItem = this.listSource.FindItem(bringIntoViewOperation.RequestedItem); if (this.initialVirtualizationItem == null) { throw new ArgumentException("Specified item does not exist in the Items Source."); } this.RecycleAllItems(); this.ApplyScrollOffsetForItem(this.initialVirtualizationItem, bringIntoViewOperation.LastAverageItemLength); this.BeginAsyncBalance(); } else { // If the item is realized, calculate the smallest amount that the item can be offset so that it is fully visible in the viewport. double offset = this.GetRealizedItemBringIntoViewOffset(foundItem); this.virtualizationStrategy.ScrollToOffset( offset, () => { // Perform a balance to ensure that all buffers are filled. this.SubscribeRendering(); this.BalanceVisualSpace(); }); } }