C# - OxyPlot如何向Windows窗体添加绘图

use*_*105 10 c# oxyplot

试用OxyPlot,安装和引用的包.从这里复制并粘贴示例http://docs.oxyplot.org/en/latest/getting-started/hello-windows-forms.html但它无法plot1从最后一行识别.我猜是因为控件没有添加到表单中.我该如何添加?我没有在工具箱中看到它,我尝试将控件添加到工具箱中,无法在任何地方找到它.谢谢.

小智 5

您可以通过在初始化组件方法下的表单设计器中附加这些行来手动添加绘图控件.

private void InitializeComponent()
{
    this.plot1 = new OxyPlot.WindowsForms.PlotView();
    this.SuspendLayout();
    // 
    // plot1
    // 
    this.plot1.Dock = System.Windows.Forms.DockStyle.Bottom;
    this.plot1.Location = new System.Drawing.Point(0, 0);
    this.plot1.Name = "plot1";
    this.plot1.PanCursor = System.Windows.Forms.Cursors.Hand;
    this.plot1.Size = new System.Drawing.Size(500,500);
    this.plot1.TabIndex = 0;
    this.plot1.Text = "plot1";
    this.plot1.ZoomHorizontalCursor = System.Windows.Forms.Cursors.SizeWE;
    this.plot1.ZoomRectangleCursor = System.Windows.Forms.Cursors.SizeNWSE;
    this.plot1.ZoomVerticalCursor = System.Windows.Forms.Cursors.SizeNS;
    this.Controls.Add(this.plot1);

    //
    // other comtrols
    //

}
private OxyPlot.WindowsForms.PlotView plot1;
Run Code Online (Sandbox Code Playgroud)