protected static Size ArrangeOverrideVertical(IStackBase stack, Size finalSize) { //var padding = Stack.Padding; //double top = padding.Top + bounds.Top; //double left = padding.Left + bounds.Left; //var height = bounds.Height - padding.VerticalThickness; var children = stack.Children; int count = children.Count; double width = finalSize.Width; double spacing = stack.Spacing; double stackHeight = 0; for (int n = 0; n < count; n++) { IUIElement child = children[n]; if (!child.Visible) { continue; } double childHeight = child.DesiredSize.Height; child.Arrange(new Rect(0, stackHeight, width, childHeight)); stackHeight += childHeight + spacing; } return(AdjustForStretchToFill(stack, width, stackHeight, finalSize)); }
protected static Size ArrangeOverrideHorizontal(IStackBase stack, Size finalSize) { //var padding = Stack.Padding; //double top = padding.Top + bounds.Top; //double left = padding.Left + bounds.Left; //var height = bounds.Height - padding.VerticalThickness; var children = stack.Children; int count = children.Count; double height = finalSize.Height; double spacing = stack.Spacing; double xPosition = 0; if (stack.FlowDirection == FlowDirection.LeftToRight) { for (int n = 0; n < count; n++) { IUIElement child = children[n]; if (!child.Visible) { continue; } double childWidth = child.DesiredSize.Width; child.Arrange(new Rect(xPosition, 0, childWidth, height)); xPosition += childWidth + spacing; } } else { for (int n = count - 1; n >= 0; n--) { IUIElement child = children[n]; if (!child.Visible) { continue; } double childWidth = child.DesiredSize.Width; child.Arrange(new Rect(xPosition, 0, childWidth, height)); xPosition += childWidth + spacing; } } return(AdjustForStretchToFill(stack, xPosition, height, finalSize)); }