private void HandleBringIntoView() { var bringIntoViewIndex = -1; var bringIntoViewMode = BringIntoViewMode.Default; if (_enqueueBringIntoViewRequest != null) { bringIntoViewMode = _enqueueBringIntoViewRequest.Mode; var frameworkElement = _enqueueBringIntoViewRequest.ElementInternal; bringIntoViewIndex = frameworkElement != null ? Source.GetIndexFromItem(frameworkElement) : _enqueueBringIntoViewRequest.Index; if (bringIntoViewIndex == -1) { bringIntoViewIndex = _enqueueBringIntoViewRequest.FallbackIndex; } } if (bringIntoViewIndex != -1) { var orientation = Orientation; var extent = Extent.AsOriented(orientation); extent.Direct = extent.Direct.Clamp(bringIntoViewIndex + Viewport.AsOriented(orientation).Direct, double.MaxValue); Offset = CalcBringIntoViewOffset(bringIntoViewIndex, bringIntoViewMode, Viewport, extent.Size, Offset); } _enqueueBringIntoViewRequest = null; }
protected override void ExecuteScrollCommand(ScrollCommandKind command) { var commandOrientation = ScrollViewUtils.GetCommandOrientation(command); var orientation = Orientation; var orientedViewport = Viewport.AsOriented(orientation); var orientedExtent = Extent.AsOriented(orientation); var orientedOffset = Offset.AsOriented(orientation); var directScrollView = new OrientedScrollView(orientation, orientedViewport.Direct, orientedExtent.Direct, orientedOffset.Direct); var indirectScrollView = new OrientedScrollView(orientation.Rotate(), orientedViewport.Indirect, orientedExtent.Indirect, orientedOffset.Indirect); directScrollView.ExecuteScrollCommand(command, commandOrientation == orientation ? ScrollViewUtils.DefaultUnitSmallChange : ScrollViewUtils.DefaultPixelSmallChange, commandOrientation == orientation ? ScrollViewUtils.DefaultUnitWheelChange : ScrollViewUtils.DefaultPixelWheelChange); indirectScrollView.ExecuteScrollCommand(command, commandOrientation != orientation ? ScrollViewUtils.DefaultUnitSmallChange : ScrollViewUtils.DefaultPixelSmallChange, commandOrientation != orientation ? ScrollViewUtils.DefaultUnitWheelChange : ScrollViewUtils.DefaultPixelWheelChange); orientedOffset.Direct = directScrollView.Offset; orientedOffset.Indirect = indirectScrollView.Offset; Offset = orientedOffset.Vector; }