Chart Legend Style

Dec 22, 2009 at 4:16 PM

Hello all.

I'm trying to use the WPF Toolkit Charts. I wanted to style them to my liking, so I copyied the Resource file provided in codeplex and edited it. So far everything's fine, I'm able to change the background, border color, etc.

Next, I wanted to pick the chart colors, so I changed the "style palette" property on the resource file. That also works fine, I change the colors and they are used for both chart and legend.

Finally, I wanted the colors to be used according to the results. So I changed the "style palette" property, creating a few triggers, for each specific value, like the following:

<Style TargetType="charting:PieDataPoint">
   <!-- Changes the color to green when the result is "A" -->
      <Trigger Property="IndependentValue" Value="A">
           <Setter Property="Background" Value="Green"/>

So what happens when I do that? The chart is colored as expected, but for some reason, the legend items colors are all changed to a default orange! I even tried to create another style, with a TargetType of "charting:LegendItem", but that doesn't seem to do anything. The really weird thing is that when I use a fixed setter the Legend Item is colored accordingly... but if I use a Trigger, it isn't.

Can anyone help me with this?

Thanks in advance!