This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to use the feature of multiple data sources in the RadChart.
Like this:
XAML:
If the Property "Data" is loaded in the constructor of my ViewModel-Class everything works well. But as soon as the Data is loaded after setting the UserControls DataContext (Button-Command), there will raise a NullReferenceException at a point that is not comprehensible to me.
ViewModel:
Hope you could give me a hint how to get this working.
I created a sample project where the "bug" happens. I'd like to send you the VS-Project as a source where you can understand what my problem is. (The project is mostly the code above)
The same problem happens also in WPF-RadChart. We recognized that while a workmate tried to implement your chart in a WPF-Project.
Regards,
Julian
I'm trying to use the feature of multiple data sources in the RadChart.
Like this:
XAML:
<
telerik:RadChart
x:Name
=
"Chart1"
>
<
telerik:RadChart.SeriesMappings
>
<
telerik:SeriesMappingCollection
>
<
telerik:SeriesMapping
x:Name
=
"Series1"
ItemsSource
=
"{Binding Data[0]}"
>
<
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:LineSeriesDefinition
/>
</
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:SeriesMapping.ItemMappings
>
<
telerik:ItemMapping
FieldName
=
"Date"
DataPointMember
=
"XValue"
/>
<
telerik:ItemMapping
FieldName
=
"Value"
DataPointMember
=
"YValue"
/>
</
telerik:SeriesMapping.ItemMappings
>
</
telerik:SeriesMapping
>
<
telerik:SeriesMapping
x:Name
=
"Series2"
ItemsSource
=
"{Binding Data[1]}"
>
<
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:LineSeriesDefinition
/>
</
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:SeriesMapping.ItemMappings
>
<
telerik:ItemMapping
FieldName
=
"Date"
DataPointMember
=
"XValue"
/>
<
telerik:ItemMapping
FieldName
=
"Value"
DataPointMember
=
"YValue"
/>
</
telerik:SeriesMapping.ItemMappings
>
</
telerik:SeriesMapping
>
</
telerik:SeriesMappingCollection
>
</
telerik:RadChart.SeriesMappings
>
</
telerik:RadChart
>
If the Property "Data" is loaded in the constructor of my ViewModel-Class everything works well. But as soon as the Data is loaded after setting the UserControls DataContext (Button-Command), there will raise a NullReferenceException at a point that is not comprehensible to me.
ViewModel:
public
class
ViewModel
{
public
ObservableCollection<ObservableCollection<ChartValueData>> Data {
get
;
set
; }
public
ICommand LoadChartCommand {
get
;
set
; }
public
ViewModel()
{
Data =
new
ObservableCollection<ObservableCollection<ChartValueData>>();
LoadChartCommand =
new
Telerik.Windows.Controls.DelegateCommand(CreateLineChartData);
}
private
void
CreateLineChartData(
object
o)
{
List<ChartValueData> list =
new
List<ChartValueData>();
Random random =
new
Random();
for
(
int
i = 0; i < 2; i++)
{
for
(
int
j = 0; j < 7; j++)
{
list.Add(
new
ChartValueData { Date =
new
DateTime(2011, j + 1, 1), Value = random.Next(11, 111) });
}
Data.Add(
new
ObservableCollection<ChartValueData>(list));
list =
new
List<ChartValueData>();
}
}
}
Hope you could give me a hint how to get this working.
I created a sample project where the "bug" happens. I'd like to send you the VS-Project as a source where you can understand what my problem is. (The project is mostly the code above)
The same problem happens also in WPF-RadChart. We recognized that while a workmate tried to implement your chart in a WPF-Project.
Regards,
Julian