Browse Source
Fix DockPanel index out of range (#18261)
* Update DockPanel.cs
* Update DockPanelTests.cs
pull/18284/head
Poker
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
17 additions and
2 deletions
-
src/Avalonia.Controls/DockPanel.cs
-
tests/Avalonia.Controls.UnitTests/DockPanelTests.cs
|
|
|
@ -179,7 +179,7 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (LastChildFill) |
|
|
|
if (LastChildFill && Children.Count > 0) |
|
|
|
{ |
|
|
|
var child = Children[Children.Count - 1]; |
|
|
|
var childConstraint = new Size( |
|
|
|
@ -265,7 +265,7 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (LastChildFill) |
|
|
|
if (LastChildFill && Children.Count > 0) |
|
|
|
{ |
|
|
|
var child = Children[Children.Count - 1]; |
|
|
|
child.Arrange(new Rect(currentBounds.X, currentBounds.Y, currentBounds.Width, currentBounds.Height)); |
|
|
|
|
|
|
|
@ -4,6 +4,21 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
{ |
|
|
|
public class DockPanelTests |
|
|
|
{ |
|
|
|
[Fact] |
|
|
|
public void DockPanel_Without_Child() |
|
|
|
{ |
|
|
|
var target = new DockPanel |
|
|
|
{ |
|
|
|
Width = 10, |
|
|
|
Height = 10 |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(Size.Infinity); |
|
|
|
target.Arrange(new Rect(target.DesiredSize)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(0, 0, 10, 10), target.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Dock_Controls_Horizontal_First() |
|
|
|
{ |
|
|
|
|