1.打开第一节新建的MVVM项目。
2.将OxyPlot.dll,OxyPlot.WindowsFroms.dll,OxyPlot.Wpf.dll和OxyPlot.Wpf.Shared.dll添加到项目的引用中。
3.新建CurveDisplayVM.cs绘制曲线的类。具体代码见附件。
4.在UserControl2.xaml页面添加一个Grid用来放置画曲线的plot。点击该Grid。在右侧的DataContext中点击新建,选择WpfApp1中的CurveDisplayVM。
此时,在UserControl2.xaml页面的XAML代码中,该Gird里会增加如下语句:
<Grid.DataContext>
<ViewModel:CurveDisplayVM/>
</Grid.DataContext>
<oxy:PlotView Model="{Binding SampWavePlot}">
</oxy:PlotView>
5.此时,运行代码就能看到曲线的初步雏形了。