I cannot get a simple RadCartesianChart to display when setting the style for a CategoricalSeriesDescriptor. I have a simple one window WPF app (I can send the project if you wish). The project has a folder called "Blah" in which the Telerik.Windows.Controls.xaml and Telerik.Windows.Controls.Chart.xaml Windows8 resource dictionaries are located (both with build action of Page). The Telerik binaries that are referenced by the project are the latest noxaml versions.
If I remove the style for the CategoricalSeriesDescriptor.Style, the chart shows as expected. If I add the style, the project will build and run, but, the chart will not draw, and the message "No data to plot" is displayed. The output shows no exceptions.
Also, when I edit the XAML, no errors are displayed in the XAML editor in VS. However, as soon as I build, the XAML editor underlines (in blue) the entire CategoricalSeriesDescriptor element. The tooltip error message for that element is 'The value "Telerik.Windows.Controls.ChartView.CategoricalSeriesDescriptor" is not of type "Telerik.WIndows.Controls.ChartView.ChartSeriesDescriptor" and cannot be used in this generic collection. Parameter name: value'
Further, if I remove the style completely, the XAML editor complains about the properties like ItemsSourcePath and TypePath. But without the style, the project runs and the chart is displayed.
Please help me figure out what I'm doing wrong. Is it something to do with the resource dictionaries & usage of the noxaml assemblies? The rest of the code is basically straight out of the examples & it's driving me crazy :(.
Thanks - Mitch
The XAML for the windows is:
<
Window
x:Class
=
"Chart3.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Window.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"pack://application:,,,/Chart3;component/Blah/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"pack://application:,,,/Chart3;component/Blah/Telerik.Windows.Controls.Chart.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
Window.Resources
>
<
Grid
>
<
telerik:RadCartesianChart
x:Name
=
"chart"
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:DateTimeCategoricalAxis
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:RadCartesianChart.SeriesProvider
>
<
telerik:ChartSeriesProvider
Source
=
"{Binding Series}"
>
<
telerik:ChartSeriesProvider.SeriesDescriptors
>
<
telerik:CategoricalSeriesDescriptor
ItemsSourcePath
=
"MyData"
CategoryPath
=
"Category"
ValuePath
=
"Value"
TypePath
=
"SeriesType"
>
<
telerik:CategoricalSeriesDescriptor.Style
>
<
Style
TargetType
=
"{x:Type telerik:LineSeries}"
>
<
Setter
Property
=
"StrokeThickness"
Value
=
"8"
/>
</
Style
>
</
telerik:CategoricalSeriesDescriptor.Style
>
</
telerik:CategoricalSeriesDescriptor
>
</
telerik:ChartSeriesProvider.SeriesDescriptors
>
</
telerik:ChartSeriesProvider
>
</
telerik:RadCartesianChart.SeriesProvider
>
</
telerik:RadCartesianChart
>
</
Grid
>
</
Window
>
and the code behind that populates the data, etc. is:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
using
System.Collections.ObjectModel;
using
Telerik.Charting;
using
Telerik.Windows.Controls.ChartView;
namespace
Chart3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
this
.DataContext =
this
;
this
.Series =
new
ObservableCollection<ChartSeries>();
//add some data.
ChartSeries series =
new
ChartSeries();
MyPoint dp =
new
MyPoint();
dp.Value = 10;
dp.Category = DateTime.Now;
series.MyData.Add(dp);
dp =
new
MyPoint();
dp.Value = 40;
dp.Category = DateTime.Now.AddMonths(2);
series.MyData.Add(dp);
dp =
new
MyPoint();
dp.Value = 20;
dp.Category = DateTime.Now.AddMonths(3);
series.MyData.Add(dp);
this
.Series.Add(series);
}
public
ObservableCollection<ChartSeries> Series
{
get
;
set
;
}
}
public
class
ChartSeries
{
public
ChartSeries()
{
this
.MyData =
new
ObservableCollection<MyPoint>();
this
.SeriesType =
typeof
(LineSeries);
}
public
Type SeriesType {
get
;
set
; }
public
ObservableCollection<MyPoint> MyData
{
get
;
set
; }
}
public
class
MyPoint
{
public
object
Category {
get
;
set
; }
public
double
? Value {
get
;
set
; }
}
}