Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Support Naming `ColumnDefinition` and `RowDefinition`

Open robloo opened this issue 10 months ago • 4 comments

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

WPF supports a Name property of both ColumnDefinition and RowDefinition. Avalonia does not.

Describe the solution you'd like

ColumnDefinition.Name and RowDefinition.Name settable from XAML and C#. Ability to lookup columns/rows by name and then set width or visiblity, etc.

Describe alternatives you've considered

No response

Additional context

Avalonia lost the name property here even though it used WPF source code for the grid because the class inheritance is different.

Column/RowDefinition in WPF inherit from FrameworkContentElement which has the name property.

I also haven't dug deeply into the Avalonia source code but since inheritance in Avalonia is ColumnDefinition : DefinitionBase : AvaloniaObject... I'm not overly optimistic this is easy to add Name support for (seems like it would need to be a control/frameworkelement).

Note that if we ever support this, Flyout is another one that would be good to support naming of.

robloo avatar Apr 27 '24 01:04 robloo

This might actually be a lot easier than I thought.

Avalonia has the INamed interface that can be implemented on any type. Not sure code generators support it directly though. Can dig further later.

robloo avatar Apr 27 '24 16:04 robloo

I think there was an attempt to implement INamed before. @jmacato might remember better.

maxkatz6 avatar Apr 30 '24 00:04 maxkatz6

@maxkatz6 sorry for the inconvenience, can you tell me if at the moment there is a workaround that would allow to get from View/ViewModel to the necessary RowDefinition without Name?

vladkryv avatar May 08 '24 11:05 vladkryv

you can bind to Width/Height. Probably using a converter.

timunie avatar May 08 '24 11:05 timunie