How to create StackedBarSeries with custom tooltip without losing standard colors
- by Simon_Weaver
I have a StackedBarSeries in Silverlight 4 charting (latest release).
I have created a DataPointStyle called MyDataPointStyle for a custom tooltip. By itself this breaks the standard palette used for the different bars.
I've applied a custom palette - as described in David Anson's blog to the chart.
However when I have the DataPointStyle set for my SeriesDefinition objects it does not use this palette.
I'm not sure what I'm missing - but David specifically says :
... it enables the use of
DynamicResource (currently only
supported by the WPF platform) to let
users customize their DataPointStyle
without inadvertently losing the
default/custom Palette colors. (Note:
A very popular request!)
Unfortunately I'm inadvertently losing these colors - and I can't see why?
<chartingToolkit:Chart.Palette>
<dataviz:ResourceDictionaryCollection>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control">
<Setter Property="Background" Value="Blue"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control">
<Setter Property="Background" Value="Green"/>
</Style>
</ResourceDictionary>
<ResourceDictionary>
<Style x:Key="DataPointStyle" TargetType="Control">
<Setter Property="Background" Value="Red"/>
</Style>
</ResourceDictionary>
</dataviz:ResourceDictionaryCollection>
</chartingToolkit:Chart.Palette>
<chartingToolkit:Chart.Series>
<chartingToolkit:StackedBarSeries>
<chartingToolkit:SeriesDefinition
IndependentValueBinding="{Binding SKU}"
DependentValueBinding="{Binding Qty}"
DataPointStyle="{StaticResource MyDataPointStyle}"
Title="Regular"/>
<chartingToolkit:SeriesDefinition
IndependentValueBinding="{Binding SKU}"
DependentValueBinding="{Binding Qty}"
DataPointStyle="{StaticResource MyDataPointStyle}"
Title="FSP Orders"/>
<chartingToolkit:StackedBarSeries.IndependentAxis>
<chartingToolkit:CategoryAxis Title="SKU" Orientation="Y" FontStyle="Italic" AxisLabelStyle="{StaticResource LeftAxisStyle}"/>
</chartingToolkit:StackedBarSeries.IndependentAxis>
<chartingToolkit:StackedBarSeries.DependentAxis>
<chartingToolkit:LinearAxis Orientation="X" ExtendRangeToOrigin="True" Minimum="0" ShowGridLines="True" />
</chartingToolkit:StackedBarSeries.DependentAxis>
</chartingToolkit:StackedBarSeries >
</chartingToolkit:Chart.Series>
</chartingToolkit:Chart>