While I’m fine with standard control styling in silverlight I have recently began using more dynamic methods of fetching data to be displayed in items controls. One of the controls I am reworking is a collection of links.
The issue I am having is that each link is coloured differently when moused over. One red, one blue, one green, etc. Is there a way to style these items without sacrificing the dynamics of using an items control with a data template?
I have done this using a simple converter on a property of the view model, for example lets say you had a boolean property that you wanted to control a style you could do this.
then as a resource you would define your two styles…
then you would apply it to your object like this…
Where IsConfirmed is a boolean property on the viewmodel, this will also keep the style in sync if the
IsConfirmedproperty changes.If you want to use a more complicated condition than a Boolean you could always create a Dictionary of objects to Styles in your converter and then have the converter do a lookup, but i have found that usually booleans work in most cases.