简述
WPF开发中经常需要绘制曲线、直方图等。虽然WPF自带了绘制图形等基础功能,但做程序一个很基础的原则就是避免重复造轮子。在GitHub上找到了微软官方的WPF绘制曲线开源库:InteractiveDataDisplay.WPF。
我使用的IDE是VS201x,建议使用NuGet安装--引用InteractiveDataDisplay.WPF。如何使用NuGet,请自行百度。
以下是我实验的该开源库绘制的WPF曲线程序。
代码
MainWindow.xaml
<Window x:Class="WpfDrawPlot.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d3="clr-namespace:InteractiveDataDisplay.WPF;assembly=InteractiveDataDisplay.WPF"
Title="MainWindow" Height="600" Width="800">
<Grid>
<Gri