Replies: 3 comments
-
The simplest way is to just use a class style binding. https://docs.avaloniaui.net/docs/guides/data-binding/binding-classes Otherwise you can also use a custom template selector in some situations. |
Beta Was this translation helpful? Give feedback.
-
There is a simplest way by add an enum to your viewmodel:
Then bind this property and use a converter to it, just like this: Of course, you have to write StatusToColorConverter yourself. I'm too lazy to write in detail, but the idea is roughly like this. |
Beta Was this translation helpful? Give feedback.
-
Big thanks for repliers. Class style binding is the easiest choice. |
Beta Was this translation helpful? Give feedback.
-
I have button in app, which changes color depending on async task in viewmodel (is microphone working - one color, not working microphone - another color) and i cant understand what is the best way to do this without breaking MVVM pattern.
Is reading ViewModel variables in Avalonia Behaviors acceptable by MVVM?
Beta Was this translation helpful? Give feedback.
All reactions