feat: initial ElasticWrapPanel.
This commit is contained in:
3
src/Ursa.Themes.Semi/Controls/ElasticWrapPanel.axaml
Normal file
3
src/Ursa.Themes.Semi/Controls/ElasticWrapPanel.axaml
Normal file
@@ -0,0 +1,3 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</ResourceDictionary>
|
||||
@@ -6,6 +6,7 @@
|
||||
<ResourceInclude Source="ButtonGroup.axaml" />
|
||||
<ResourceInclude Source="Divider.axaml" />
|
||||
<ResourceInclude Source="DualBadge.axaml" />
|
||||
<ResourceInclude Source="ElasticWrapPanel.axaml" />
|
||||
<ResourceInclude Source="IPv4Box.axaml" />
|
||||
<ResourceInclude Source="KeyGestureInput.axaml" />
|
||||
<ResourceInclude Source="Loading.axaml" />
|
||||
|
||||
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