This question is locked. New answers and comments are not allowed.
I'm trying to style a stacked bar panel and running into some problems. The definition of the panel looks like this:
The StatusCounts is a IEnumerable<T> where T is an object that has the Count and StatusDescription fields. In the code behind, I do this:
And then:
The problem is ... the create item style is never called! I set a breakpoint and it never fires. The chart is rendering fine, I see axis labels and lables on the items, etc, but I never get the create item style delegate to fire so I can colorize the data items. Help!
| <Controls:RadChart |
| x:Name="StatusChart" |
| HorizontalAlignment="Stretch" |
| HorizontalContentAlignment="Stretch" |
| ItemsSource="{Binding StatusCounts}"> |
| <Controls:RadChart.DefaultView> |
| <Charting:ChartDefaultView> |
| <Charting:ChartDefaultView.ChartLegend> |
| <Charting:ChartLegend Visibility="Collapsed"/> |
| </Charting:ChartDefaultView.ChartLegend> |
| <Charting:ChartDefaultView.ChartArea> |
| <Charting:ChartArea |
| EnableStripLinesAnimation="True" |
| EnableAnimations="True" |
| ItemWidthPercent="90" |
| HorizontalAlignment="Stretch" |
| HorizontalContentAlignment="Stretch"/> |
| </Charting:ChartDefaultView.ChartArea> |
| </Charting:ChartDefaultView> |
| </Controls:RadChart.DefaultView> |
| <Controls:RadChart.SeriesMappings> |
| <Charting:SeriesMapping> |
| <Charting:SeriesMapping.SeriesDefinition> |
| <Charting:Bar3DSeriesDefinition ShowItemLabels="True"/> |
| </Charting:SeriesMapping.SeriesDefinition> |
| <Charting:SeriesMapping.ItemMappings> |
| <Charting:ItemMapping FieldName="Count" DataPointMember="YValue"/> |
| <Charting:ItemMapping FieldName="StatusDescription" DataPointMember="XCategory"/> |
| </Charting:SeriesMapping.ItemMappings> |
| </Charting:SeriesMapping> |
| </Controls:RadChart.SeriesMappings> |
| </Controls:RadChart> |
The StatusCounts is a IEnumerable<T> where T is an object that has the Count and StatusDescription fields. In the code behind, I do this:
| public StatusChartControl() |
| { |
| InitializeComponent(); |
| StatusChart.CreateItemStyleDelegate = CreateItemStyle; |
| } |
And then:
| public Style CreateItemStyle(Control control, Style baseStyle, DataPoint dataPoint, DataSeries dataSeries) |
| { |
| if (control is ChartLegendItem || dataPoint == null) |
| { |
| return baseStyle; |
| } |
| // Create a new style, do not use the one that is provided as parameter. |
| var newStyle = new Style(baseStyle.TargetType) {BasedOn = baseStyle}; |
| var brush = ((StatusCount) dataPoint.DataItem).Region.AsBrush(); |
| if (control is BaseChartItem2D) |
| newStyle.Setters.Add(new Setter(Shape.FillProperty, brush)); |
| if (control is SeriesItemLabel) |
| newStyle.Setters.Add(new Setter(SeriesItemLabel.FillProperty, brush)); |
| return newStyle; |
| } |
The problem is ... the create item style is never called! I set a breakpoint and it never fires. The chart is rendering fine, I see axis labels and lables on the items, etc, but I never get the create item style delegate to fire so I can colorize the data items. Help!