Search code examples
c#wpflivecharts

Incorporating Community UI Elements into "Default" WPF Apps


I'm attempting to follow the tutorial on https://lvcharts.net/App/examples/v1/wpf/Material%20Design so that I can use "The Current Chart" chart to visualize CPU usage on a machine.

I have created a new default WPF application in Visual Studio Pro 2017. From there, I overwrote the contents of MainWindow.xaml and the codebehind with the code snippets from the tutorial. However, there are other prerequisite steps I'm missing because I have errors both in the xaml and the code behind citing missing assembly references, e.g.:

From xaml:

<Style TargetType="lvc:LineSeries"

The name "LineSeries" does not exist in the namespace "clr-namepsace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"

From codebehind:

using LiveCharts;

The type or namespace name "LiveCharts" could not be find (are you missing a using directive or an assembly reference?)

I'm not completely inexperienced with WPF development, but I've never attempted to use non-standard elements before. Is there a general guide I can consult that fills in the gaps of how to utilize community solutions?


Solution

  • You need to download and reference the LiveCharts assemblies. The easiest way to do this is to use NuGet.

    Select Tools->NuGet Package Manager->Package Manager Console in Visual Studio and run the following command in the Package Manager Console:

    Install-Package LiveCharts.Wpf
    

    This will download and reference the assemblies needed for you to be able to build the application.