feat: initial ElasticWrapPanel.

This commit is contained in:
Zhang Dian
2023-09-07 15:31:39 +08:00
parent 80fc6ffa7b
commit 4f16723cd5
9 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using Avalonia;
using Avalonia.Controls;
namespace Ursa.Controls;
public class ElasticWrapPanel : Panel
{
protected override Size MeasureOverride(Size availableSize)
{
var panelDesiredSize = new Size();
foreach (var child in Children)
{
child.Measure(availableSize);
panelDesiredSize = child.DesiredSize;
}
return panelDesiredSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (var child in Children)
{
const double x = 50;
const double y = 50;
child.Arrange(new Rect(new Point(x, y), child.DesiredSize));
}
return finalSize;
}
}