Search code examples
mdriven

StateMachines and colour changes


If my state machine goes to "Agreement" i want the state to be green everywhere, if it goes to "Rejection" i want it to go red everywhere. What is the most efficient way to do this?

Thanks!


Solution

  • State is a property on your object - you show that property in a view - when you show it also add an style-expression - and reference a style defined with StylesInModel. One efficient way is declare style names like: Contract_Agreement and Contract_Rejection, make them green and red. Then set the style-expression to 'Contract_'+self.State , this way when the state changes the style does to.