This section is under construction. Please contribute!

This example shows how to create a Silverlight application where the content of the plot is defined in code.

Create project

Start Visual Studio and select “FILE -> New -> Project…” to create a new Silverlight application:


Add references

You need references to the OxyPlot and OxyPlot.Silverlight assemblies. The easiest way to do this is to right click on the “References” item in the Solution Explorer and select “Manage NuGet Packages…” (this requires that the “NuGet Package Manager” extension is installed):


In the “Manage NuGet packages” dialog, search for “OxyPlot” in the top-right search textbox. Select the “OxyPlot.Silverlight” package and click install:


You can also use the [Package Manager Console]( to install the package:

PM> Install-Package OxyPlot.Silverlight

Create a view model

Add a class that creates a PlotModel and a FunctionSeries.

namespace SilverlightApplication1
    using System;

    using OxyPlot;
    using OxyPlot.Series;

    public class MainViewModel
        public MainViewModel()
            this.MyModel = new PlotModel { Title = "Example 1" };
            this.MyModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

        public PlotModel MyModel { get; set; }

Create the view

Define the namespace in the Window element, set the DataContext and add a PlotView control:

<UserControl x:Class="SilverlightApplication1.MainPage"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <oxy:PlotView Model="{Binding MyModel}"/>

The application should now look like this:

The source code can be found in the HelloWorld\SilverlightApplication1 folder in the documentation-examples repository.