From 4b978675e0fa0586d7a45ca07c34553128ac9213 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 22 May 2018 12:11:50 +0200 Subject: [PATCH] Handle child HorizontalAlignment in ScrollingVerticalStackPanel --- .../Controls/ScrollingVerticalStackPanel.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/GitHub.UI/Controls/ScrollingVerticalStackPanel.cs b/src/GitHub.UI/Controls/ScrollingVerticalStackPanel.cs index 5e423ba8c1..5ca669ca68 100644 --- a/src/GitHub.UI/Controls/ScrollingVerticalStackPanel.cs +++ b/src/GitHub.UI/Controls/ScrollingVerticalStackPanel.cs @@ -179,7 +179,25 @@ protected override Size ArrangeOverride(Size finalSize) { var isFixed = GetIsFixed(child); var x = isFixed ? 0 : -HorizontalOffset; - var childRect = new Rect(x, y, child.DesiredSize.Width, child.DesiredSize.Height); + var width = child.DesiredSize.Width; + + if (isFixed) + { + switch (child.HorizontalAlignment) + { + case HorizontalAlignment.Stretch: + width = finalSize.Width; + break; + case HorizontalAlignment.Right: + x = finalSize.Width - child.DesiredSize.Width; + break; + case HorizontalAlignment.Center: + x = (finalSize.Width - child.DesiredSize.Width) / 2; + break; + } + } + + var childRect = new Rect(x, y, width, child.DesiredSize.Height); child.Arrange(childRect); y += child.DesiredSize.Height;