5

I have a page where I want to put a chart using WinRT Xaml Toolkit Data Visualization Controls.

I have the following code:

   <Charting:Chart x:Name="PieChart" Width="400" Height="400">
        <Charting:Chart.Series>
            <Charting:PieSeries IndependentValuePath="X" DependentValuePath="Y"/>
        </Charting:Chart.Series>
    </Charting:Chart>

VS tells me, PieSeries is wrong: "A value of type 'PieSeries' cannot be added to a collection or dictionary of type 'Collection`1'".

Why is this an error?

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
Daniel
  • 318
  • 6
  • 20
  • The author of the toolkit basically says you need to work around it. https://winrtxamltoolkit.codeplex.com/workitem/810 – Jim Yarbro Feb 18 '15 at 13:30

1 Answers1

0

It's not fully tested, but it seems like this is what the sample does right now, could you do something similar?

<charting:Chart
    x:Name="PieChart"
    Title="Pie Chart"
    Margin="70,0">
    <charting:Chart.Series>
        <Series:PieSeries
            Title="Population"
            ItemsSource="{Binding Items}"
            IndependentValueBinding="{Binding Name}"
            DependentValueBinding="{Binding Value}"
            IsSelectionEnabled="True" />
    </charting:Chart.Series>
</charting:Chart>
Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
  • What is the `charting` and the `Series` namespace? (I assume that charting is `WinRTXamlToolkit.Controls.DataVisualization.Charting`.) I have already tried `WinRTXamlToolkit.Controls.DataVisualization.Charting.Series`. – Daniel Apr 22 '14 at 21:12
  • I think they're both the same namespace now. The separate XML namespaces are just an artifact of some earlier refactoring. I suspect your error is simply due to bug in the code and so you might be best off by referencing the source code for the library (you need DataVisualization + base WinRTXamlToolkit) and debug it to see what's going on. – Filip Skakun Apr 22 '14 at 21:21
  • If they are the same namespace, I still have the problem. But if I start a blank application, it works fine. But anyway, thank you. – Daniel Apr 22 '14 at 21:24