Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Fill Alignment

Open Shadowblitz16 opened this issue 10 months ago • 3 comments

Is your feature request related to a problem? Please describe.

I am trying to do something like godot's vbox and hbox containers where I can put items in and they stack on top of eachother,

But the issue is that in godot you can tell items to take up all remaining space and share it evenly with other items set to fill.

This is not possible in avalonia without grid, But grid required manually specifiying a rows and columns for each item and the row and columns definitions for every grid.

I just want them to stack horizontally or vertically and have the ability to either set the stack panel to fill it's item's evenly or tell the item in the stack panel to take4 up as much space as possiable sharing it with it's siblings.

Describe the solution you'd like

  1. Add HorizontalAlignment.Fill to Control
  2. Add VerticalAlignment.Fill to Control
  3. Add DefaultItemHorizontalAlignment to StackPanel
  4. Add DefaultItemVerticalAlignment to StackPanel

Describe alternatives you've considered

using grid and manually specifying everything

Additional context

Fill mode would take up as much remaining space as possible sharing it with it's siblings. this means if you have two children with fill mode they take up all the space remaining divided by two with margins and padding removed.

Shadowblitz16 avatar Jun 15 '25 18:06 Shadowblitz16

See also https://github.com/AvaloniaUI/Avalonia/issues/16962

using grid and manually specifying everything

There was the old auto grid control which is probably close to what you want. But it has not been updated in years at this point and is likely very broken.

https://github.com/AvaloniaUI/AvaloniaAutoGrid

Fill mode would take up as much remaining space as possible sharing it with it's siblings.

For a Stack Panel this probably does not make sense. My understanding is Stack Panels sort of have infinite width/height. So there is no "remaining" space for it to take up. A grid on the other hand uses specific cells with finite dimensions. You could make a custom panel that does this though,

thevortexcloud avatar Jun 16 '25 08:06 thevortexcloud

Is a stack panel the same as a box container? They act similar, and if they are the dimensions would be the size of the stack panel.

Shadowblitz16 avatar Jun 16 '25 22:06 Shadowblitz16

I don't know what you mean by box container, but as far as I am aware a stack panel has infinite space in a single direction. You can see that by putting lots of stuff in a stack panel without a scroll viewer. In which case the contents will likely exceed the bounds of the stack panel/window. You can work around that by putting the stack panel itself in a container with finite dimensions (EG a grid).

The actual stack panel bounds are only used for the direction opposite the orientation.

thevortexcloud avatar Jun 16 '25 23:06 thevortexcloud