4

I have a Chart from Win RT Xaml Toolkit that I want to display a ColumnSeries like this:

<charting:Chart Name="columnChart" Grid.Row="1" Grid.Column="1" Width="400" Height="400">
    <charting:Chart.Series>
        <charting:ColumnSeries  
             ItemsSource="{Binding items}"
             IndependentValueBinding="{Binding Name}"
             DependentValueBinding="{Binding Value}" 
             IsSelectionEnabled="True">
        </charting:ColumnSeries>  
    </charting:Chart.Series>
</charting:Chart>

but I always receive this error:

WinRT information: Cannot add instance of type 'WinRTXamlToolkit.Controls.DataVisualization.Charting.ColumnSeries' to a collection of type 'System.Collections.ObjectModel.Collection<WinRTXamlToolkit.Controls.DataVisualization.Charting.ISeries>'

What can be the reason for this?

Gabriel Rainha
  • 1,713
  • 1
  • 21
  • 34
Mina Wissa
  • 10,923
  • 13
  • 90
  • 158

1 Answers1

4

OK I found it,

The error was the ColumnSeries was missing the Title attribute, like this:

<charting:Chart Name="columnChart" Grid.Row="1" Grid.Column="1" Width="400" Height="400">
    <charting:Chart.Series>
        <charting:ColumnSeries  
             Title="Chart Title"
             ItemsSource="{Binding items}"
             IndependentValueBinding="{Binding Name}"
             DependentValueBinding="{Binding Value}" 
             IsSelectionEnabled="True">
        </charting:ColumnSeries>  
    </charting:Chart.Series>
</charting:Chart>

It seems that the Title attribute is mandatory.

Gabriel Rainha
  • 1,713
  • 1
  • 21
  • 34
Mina Wissa
  • 10,923
  • 13
  • 90
  • 158
  • 2
    I am finding I constantly get Errors such as A value of type 'BarSeries' cannot be added to a collection or dictionary of type 'Collection`1' which is v similar. (Using win 8.1 and v 1.6.0.5) Adding Title doesn't help. – MemeDeveloper Apr 14 '14 at 22:06
  • For some reason adding `Title` worked... I also forgot to put ` into a `` – Bas Peeters Jul 08 '15 at 20:47
  • Just so that people know, this solution also works for the **LineSeries**, which presents the same problem when used without the **Title** property. – Gabriel Rainha Oct 13 '16 at 20:49