AvaloniaUI / Avalonia.Xaml.Behaviors

Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
MIT License
385 stars 46 forks source link

Setting Behaviors via Styles is not additive #132

Closed SuperJMN closed 7 months ago

SuperJMN commented 1 year ago

If StyleA sets Behavior1 to MyControl AND AFTER THAT StyleB sets Behavior2 to MyControl

THEN StyleB will prevail and Behavior1 won't be attached.

This means that scenarios in which require several Behaviors to be applied by different Styles aren't possible.

This is my scenario: I have a Style that applies ShowSuggestionFlyoutBehavior to a TextBox that is part of another control (DecimalTextEntry), and DecimalTextEntry has a Style that sets a NumberBoxBehavior to the same TextBox.

This means that both styles (each one in a different level of abstraction) are in conflict. There should be a way to combine the behaviors from each BehaviorCollection.

wieslawsoltes commented 1 year ago

Well BehaviorCollection is using same mechanism as data templates, not sure if it's possible to make it work like that. There is some mechanism for setting multiple transforms using special type but not sure it will work in similar way for behaviours collection.

wieslawsoltes commented 1 year ago

I think to make this work we would need some Xaml compiler support