feat: initial ElasticWrapPanel.
This commit is contained in:
33
src/Ursa/Controls/ElasticWrapPanel.cs
Normal file
33
src/Ursa/Controls/ElasticWrapPanel.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user