I have a very wierd issue with style of Silverlight Charting controls. When I create a DataPointStyle for anyseries It ignore the existing default color combination. It starts showing me same(orange) color for everything even I haven’t set anything in the background of DataPointStyle.
What I want is to create some custom tooltip and leave the background as it is. But its not working for me. Any suggestion is much appreciated.
Cheers!
Vinod
I think the trick is not to apply the data-point style to the chart itself, but rather to the individual colours that make up the palette.
I started with the following, which uses a PieChart. The same principles should apply when using other types of chart:
This gave me a pie chart with the customised tooltip text but with all segments orange.
The next step is to set a custom palette. A palette used by the Silverlight Toolkit charts is a
ResourceDictionaryCollection, with each containedResourceDictionaryrepresenting a colour within the palette. You can find the ‘default’ palette for the chart withinThemes\generic.xamlin the assemblySystem.Windows.Controls.DataVisualization.Toolkit. You can use a tool such as Blend or ILSpy to get at this palette.I took this ‘default’ palette, and:
DataShapeStyle(I’m not sure they’re necessary, but you can keep them if you wish),TargetTypeof eachDataPointStylefromControltotoolkit:DataPoint, andBasedOn="{StaticResource pointStyle}"to eachDataPointStyle.This last point is what sets up the custom tooltip format with each palette entry.
This left me with something like the following, which I added to
<UserControl.Resources>:I then removed
DataPointStyle="{StaticResource pointStyle}"from thePieSeriesand addedPalette="{StaticResource chartPalette}"to the<toolkit:Chart>element instead. When I ran the application I got the four segments of the pie to use different colours.Acknowledgement: most of this has been taken from atomlinson’s post on the Silverlight forums at http://forums.silverlight.net/post/330170.aspx.