1
votes

I'm creating a KPI like control and would like to apply multiple styles based on a specific criteria without having to walk through multiple controls. Basically I have:

<Border>
  <TextBlock>
</Border>

The border needs a style as do the TextBlocks within it. I have the typical green/yellow/red KPI, but there are two modes for each. The closer you get to a deadline, the more extreme.

So for the LongTermGreen, the border would have green border w/ a transparent background and the font color of the TextBlocks would be green. But for the ShortTermGreen, I want to instead make the border dark green and the font color of the TextBlock white.

Obviously I could do this with custom code and handle setting the style based on specific criteria, but that's messy (some KPIs have multiple TextBlocks.

Is this possible? So far I have been coming up blank...

1

1 Answers

0
votes

WPF has data triggers for this exact reason, but those unfortunately have not made it into Silverlight.

This might be unconventional, but you could bind the style property to the KPI status and then use a custom converter that returns the correct style resource for the appropriate status value.

Otherwise, custom code is the only other alternative.