protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins) { // calculate the remaining space for the child after having removed the padding space. ViewPort = finalSizeWithoutMargins; // arrange the content if (VisualContent != null) { // calculate the final size given to the child (scroll view virtual size) var childSizeWithoutPadding = CalculateSizeWithoutThickness(ref finalSizeWithoutMargins, ref padding); foreach (var index in ScrollModeToDirectionIndices[ScrollMode]) { if (ContentAsScrollInfo == null || !ContentAsScrollInfo.CanScroll((Orientation)index)) { childSizeWithoutPadding[index] = Math.Max(VisualContent.DesiredSizeWithMargins[index], childSizeWithoutPadding[index]); } } // arrange the child VisualContent.Arrange(childSizeWithoutPadding, IsCollapsed); // update the scrolling bars UpdateScrollingBarsSize(); // update the scrolling if (scrollingRequests.Count > 0) { // perform the scrolling requests foreach (var request in scrollingRequests) { var scrollPosition = request.IsRelative ? ScrollOffsets - request.ScrollValue : -request.ScrollValue; UpdateScrollOffsets(scrollPosition); } } else { UpdateScrollOffsets(ScrollOffsets); // insures that scrolling is not out of bounds } // update the position of the child UpdateVisualContentArrangeMatrix(); } scrollingRequests.Clear(); return(finalSizeWithoutMargins); }
protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins) { // arrange the content if (VisualContent != null) { // calculate the remaining space for the child after having removed the padding and border space. var availableLessBorders = CalculateSizeWithoutThickness(ref finalSizeWithoutMargins, ref borderThickness); var childSizeWithoutPadding = CalculateSizeWithoutThickness(ref availableLessBorders, ref padding); // arrange the child VisualContent.Arrange(childSizeWithoutPadding, IsCollapsed); // compute the rendering offsets of the child element wrt the parent origin (0,0,0) var childOffsets = new Vector3(padding.Left + borderThickness.Left, padding.Top + borderThickness.Top, padding.Front + borderThickness.Front) - finalSizeWithoutMargins / 2; // set the arrange matrix of the child. VisualContent.DependencyProperties.Set(ContentArrangeMatrixPropertyKey, Matrix.Translation(childOffsets)); } return(finalSizeWithoutMargins); }