Cannot create WPF control

Jul 19, 2012 at 9:29 PM

This looks like a great tool, but I'm having a hard time getting to first base.  I'm a newbie with WPF, though.  I'm using VS 2010, and used NuGet to install the OxyPlot packages into my project.  OxyPlot, OxyPlot.Wpf and others now show up in my References.

The second bullet step I'm to do is to "Create a PlotModel in your ViewModel."  What the heck is a ViewModel?

In my XAML, I added a line


in my Window element.  Then in my Grid element beneath, I added

<oxy:Plot Model="{Binding myPlotModel}" Height="401" HorizontalAlignment="Left" Margin="222,12,0,0" VerticalAlignment="Top" IsEnabled="False" Background="#FFF2F296" BorderThickness="1" Width="573"/>

Then back in my MainWindow c# code, I added the WPFExample1 code you have, but when I build it complains that 'myPlotModel' does not exist in the current context.  I then added a Name="myPlotModel" attribute in the XAML and it no longer complained, but in the last line -- myPlotModel = temp; -- it gave me a type conversion error, saying that it can't convert OxyPlot.PlotModel to OxyPlot.Wpf.Plot.

I'm guessing I'm doing some basic VS or C# mis-step, that has nothing to do with OxyPlot, but I've played around with OxyPlot and OxyPlot.Wpf references and I get one error or another.

Sorry for taking your time on a noob question, but what am I doing wrong in the package references and/or XAML?


Jul 24, 2012 at 4:36 PM

So the "ViewModel" referred to is the new MVVM religion?

Jul 27, 2012 at 9:36 AM

Plot and PlotModel are completely different. You can't assign an instance of PlotModel to a Plot.

You should define myPlotModel in a ViewModel and assign the DataContext of the View (the MainWindow) to the ViewModel.

For more details, refer to the examples in the source code.

Jul 27, 2012 at 12:54 PM

Yeah, somehow I missed a statement on that there were examples in the Source Code.  I figured that out two days ago and have been playing.  The code above that I tried to use was based on what is shown on  Thanx.

Aug 8, 2012 at 10:13 PM

Yes, most WPF/SL examples are using the MVVM design pattern. I will not add examples using named plot controls (even if it is possible) as I don't think this is good practice.

Will try to improve the 'getting started' documentation as soon as I get time! 

Nov 5, 2013 at 12:42 PM
I'll take it time was not kind to you, good ser? :)
Nov 5, 2013 at 5:55 PM
:) You're right! Time is passing more quickly than it used to! But documentation is coming, I am working on it :) If anyone really likes writing documentation and would like to give a hand, please shout out!
Nov 6, 2013 at 2:40 AM
Howling into the night ...

Nobody likes writing documentation, everybody loves reading it and complains if it's not there ...
That's what differentiates good code from bad code ...

Having said that, how could I help?
Nov 6, 2013 at 10:04 PM
I will submit what I have 'very' soon! The documentation will be written in wiki syntax as plain text files under a new ~/Documentation folder. Create a fork and make a pull request when ready. The build machine will convert the wiki files to html, chm and pdf, and upload to The API documentation will be generated from the XML comments and also included there. This should make everything googlable!