C # - OxyPlot how to add a graph to a window shape

An attempt to use OxyPlot, installed and related packages. Copy and paste the example here http://docs.oxyplot.org/en/latest/getting-started/hello-windows-forms.html , but it does not recognize plot1 from the last line. I suppose because the control is not added to the form. How to add it? I do not see it in the toolbar, and I tried to add a control to the toolbar and cannot find it anywhere. Thanks.

+7
c # oxyplot
source share
3 answers

You can add Manage Drawings Manually by adding these lines to the form designer using the component's initialize method.

 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; 
+5
source share

You said, "I tried to add a control to the toolbar and cannot find it anywhere." He may not have found your installation of Oxyplot.WindowsForms. While in your visual studio project, after you right-click on the toolbar, click ".NET Framework Components" and then click "Browse" and look for "OxyPlot.WindowsForms.dll". If you installed it in your project, it should be in one of the package subfolders, such as the \\ lib folders.

+2
source share

I had this problem myself. I tried to add the link (right-click the link in Solution Explorer, then browse the "OxyPlot.dll" and "OxyPlot.WindowsForms.dll" files). It didn't work at first; I got an error all the time.

I noticed that there were two versions of "Oxyplot.dll", net40 and net45. I originally used the net45 version. I copied the version of net40 to the same place as "OxyPlot.WindowsForms.dll", added Link, went to the toolbar, added a new tab, then added a link to the tab (right-click mouse tab → "Select Items", then search for Oxyplot )

Now I have a pointer and PlotView in the toolbar. I am using the VS2017 community with the Forms application. The manual version above worked for me as well.

+1
source share

All Articles