Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 7c18a9f

Browse files
authored
Merge pull request #1702 from github/fixes/scrollingverticalstackpanel-alignment
Handle child HorizontalAlignment in ScrollingVerticalStackPanel
2 parents 147daf0 + 73d4fb1 commit 7c18a9f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/GitHub.UI/Controls/ScrollingVerticalStackPanel.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,25 @@ protected override Size ArrangeOverride(Size finalSize)
179179
{
180180
var isFixed = GetIsFixed(child);
181181
var x = isFixed ? 0 : -HorizontalOffset;
182-
var childRect = new Rect(x, y, child.DesiredSize.Width, child.DesiredSize.Height);
182+
var width = child.DesiredSize.Width;
183+
184+
if (isFixed)
185+
{
186+
switch (child.HorizontalAlignment)
187+
{
188+
case HorizontalAlignment.Stretch:
189+
width = finalSize.Width;
190+
break;
191+
case HorizontalAlignment.Right:
192+
x = finalSize.Width - child.DesiredSize.Width;
193+
break;
194+
case HorizontalAlignment.Center:
195+
x = (finalSize.Width - child.DesiredSize.Width) / 2;
196+
break;
197+
}
198+
}
199+
200+
var childRect = new Rect(x, y, width, child.DesiredSize.Height);
183201
child.Arrange(childRect);
184202
y += child.DesiredSize.Height;
185203

0 commit comments

Comments
 (0)