Enum collection binding with CompiledBinding. #17017
-
I have a DataTemplate, which contains a ComboBox with an Enum in SelectedItem. I would like to provide a collection of enumerations Enum.GetValues(type) in ItemsSource without creating a separate property in the interface that will store this collection, with support for CompiledBindings.
How can I solve the problem? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Ursa provides a EnumSelector control. you can refer to its design. it is AOT compatible. https://github.com/irihitech/Ursa.Avalonia/tree/main/src/Ursa/Controls/EnumSelector |
Beta Was this translation helpful? Give feedback.
-
Looks more like a bug. Tried with an additional property that contained an Enum collection, but it doesn't work. It doesn't work not only with ComboBox, but also with ListBox, that is, with list controls that have a selected element. |
Beta Was this translation helpful? Give feedback.
-
Not sure if this is what you want, I usually initialize enum collection like this:
And then bind the This is also available in CompiledBinding. |
Beta Was this translation helpful? Give feedback.
Your Status property in ITask doesn't have a Setter, that's why you can't set it.
Everything else works because both Getter and Setter are specified in the more specific ITaskElement interface. Only Status is left entirely inherited.