I have pretty simple scenario (MVVM)
DataTemplate visuals should change based on data I bind to. Let’s say based on some data I want background to be Red or Green
On one side it seems like 2 different Visual states “Valid” and “Invalid”. However, I can’t figure out how to bind to VisualState properly. I find examples online how to do this with code but I’m not sure if it is defeating the purpose.
Another way it to write Value Converter and bind color directly to value in my object which seems to be straightforward way. And no Visual Templates needed.
What do you think? Where I should use Visual States and where I should use binding with converters?
As the name VisualStateManger implies, the VSM is used to display a visual state. To use the VSM is just a way to keep something easier. In the case of just replaced a color, a Converter is sufficient whereas the VSM can also be used. In certain scenarios, the VSM provides more capabilities. Have a look here http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx. So, it depends on the requirements. Could you give us more information about your problem and what exactly you want to do?