protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins) { // measure size desired by the children var childDesiredSizeWithMargins = Vector3.Zero; if (VisualContent != null) { // remove space for padding in availableSizeWithoutMargins var childAvailableSizeWithMargins = CalculateSizeWithoutThickness(ref availableSizeWithoutMargins, ref padding); // if the content is not scrollable perform space virtualization from the scroll viewer side. foreach (var index in ScrollModeToDirectionIndices[ScrollMode]) { if (ContentAsScrollInfo != null && ContentAsScrollInfo.CanScroll((Orientation)index)) { continue; } childAvailableSizeWithMargins[index] = float.PositiveInfinity; } VisualContent.Measure(childAvailableSizeWithMargins); childDesiredSizeWithMargins = VisualContent.DesiredSizeWithMargins; } // add the padding to the child desired size var desiredSizeWithPadding = CalculateSizeWithThickness(ref childDesiredSizeWithMargins, ref padding); return(desiredSizeWithPadding); }
protected void switchVisualContent(VisualContent _visualContent) { switch (_visualContent) { case VisualContent.Loading: MainGrid.Visibility = System.Windows.Visibility.Hidden; MainGridStartup.Visibility = System.Windows.Visibility.Visible; break; case VisualContent.Main: MainGridStartup.Visibility = System.Windows.Visibility.Hidden; MainGrid.Visibility = System.Windows.Visibility.Visible; break; } }
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); }