Reputation: 301
Noob question guys: I'm trying to understand WPF technology, and specifically I will have a project that needs charts. I have added the reference
In the XAML i was advised to add: (taken from here : https://mitchelsellers.com/blogs/2011/04/20/wpf-chart-styling-explained)
xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
However when it then try add a Chart in the XAML it gives the following error.
Severity Code Description Project File Line Suppression State Error The name "chart" does not exist in the namespace "clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit". Error The type 'charting:chart' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built Error The tag 'chart' does not exist in XML namespace 'clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit'.
What am I missing/not understanding?
The XAML gives the following error.
But when i look at the Toolkit in the object browser, i see the charting/chart
Upvotes: 2
Views: 9382
Reputation: 240
I have found working with the various toolkits from yesteryear to be a bit frustrating. NuGet is typically my savior, offering libraries directly without installing anything outside of my IDE.
A note for future posts to is to provide the actual trouble code, like the MainWindow.xaml.
I created a working example here.
As noted above, I try to use NuGet now for these things. The object you're looking for is in System.Windows.Controls.DataVisualization.Toolkit
. The namespaces you're looking for can now be referenced here:
Once those are added, you can add your chart:
<chartingToolkit:Chart x:Name="chtSummary" Width="770" Height="400" Title="My Chart Title">
...
</chartingToolkit:Chart>
Again, see the github repo for a working example. Good luck!
Upvotes: 3