Avalonia.FuncUI icon indicating copy to clipboard operation
Avalonia.FuncUI copied to clipboard

Can't get Grid sizing scopes to work in FuncUI

Open marklam opened this issue 1 year ago • 7 comments

I've made a sample repo at https://github.com/marklam/GridSizingScopes

The sample code from https://docs.avaloniaui.net/docs/reference/controls/grid/sharedsizegroup is replicated in F# in the XamlGrids project.

An attempt to recreate this in FuncUI is in the FuncUIGrids project.

The XamlGrids version sizes the groups A, B and C (columns 1, 2 and 4) to their content. The FuncUI version sizes all the columns as if they were of width 1*

XamlGrids: image

FuncUIGrids: image

Is there something I'm missing? It doesn't seem like this should be object graph / diff related, but I'm not sure.

marklam avatar Dec 19 '24 19:12 marklam

Hey @marklam

interesting bug, after looking at it briefly I don't not see anything obvious. Can take a closer look tomorrow

XAML Version:

image

FuncUI Version:

image

JaggerJo avatar Dec 19 '24 19:12 JaggerJo

Thanks for taking the time to look at it.

Yes, the diagnostics view doesn't give much insight into size scopes, unfortunately.

I pushed a new changeset to make the UI trees match (ItemsControl with ContentPresenter instead of ListBox with ListBoxItem/HostControl) but it doesn't change the sizing.

marklam avatar Dec 19 '24 20:12 marklam

Hey @marklam

Did you manage to make any progress by yourself?

JaggerJo avatar Jan 13 '25 09:01 JaggerJo

No luck sadly, @JaggerJo

I had hoed that it was down to the layout hierarchy, but when that didn't fix it, I ended up just picking an adequate-looking fixed size as a workaround.

marklam avatar Jan 13 '25 10:01 marklam

@marklam

I'm currently pretty time constrained.. I think this needs a full day of attention as it's not obvious why the exact same layout leads to different behaviour. SharedSizeScope seems to be not heavily used, I can image it containing some edge cases.

Would be interesting if the issue still exists if you create the UI tree in code (not FuncUI, raw F#/C#). Then we could isolate if it's XAML magic that's making it, or FuncUI breaking it 🙃

JaggerJo avatar Jan 13 '25 10:01 JaggerJo

Based in what I had to do for Fabulous.Avalonia to support this. I think the logic for Row and Column definitions needs to be updated .

Context: https://github.com/fabulous-dev/Fabulous.Avalonia/pull/273/files

edgarfgp avatar Jan 13 '25 10:01 edgarfgp

Hey @edgarfgp 👋

hmm, @marklam also sets SharedSizeGroup columns, see:

https://github.com/marklam/GridSizingScopes/blob/51619b3a6e2ffabedc66985ac8c3c7cb4ea657a6/FuncUIGrids/Program.fs#L42-L47

What am I missing here?

JaggerJo avatar Jan 13 '25 10:01 JaggerJo