For different user interfaces I want to show an image depending on a state of a ViewModel object.
For example:
I have a database connection, if connected, I want to show a green database image, if not connected I want to display a red database image.
In the ViewModel there is a bool
that represents the state.
Possibilities are:
Having two images in the view (with a converter InverseBooleanToVisibilityConverter for the red image), which are at the same place, actually just showing one of them.
Binding for
Image source
(but I do not want to set this in my ViewModel)Some sort of selector?
This state depending image can be more often of use, e.g. in a TreeView
as ItemImage
.
Is there a more clever way to accomplish that?