[英]Drawing a simple graph with WPF
I am looking to do some simple drawing with in a WPF application, I was wondering if this is a simple task or if I should look into some 3rd party libraries. 我想在WPF应用程序中进行一些简单的绘图,我想知道这是否是一个简单的任务,还是我应该研究一些第三方库。
Quite simply I just want to draw on an image control some points and lines between those points. 很简单,我只想在图像控件上绘制一些点和这些点之间的线。 Is this something easy to do?
这容易做到吗?
thanks! 谢谢!
for a sample to use ..you can draw a line using basics only... 为了使样品使用..您只能使用基础知识来画线...
how to set canvas backgroud as image.. 如何将画布背景设置为图像
ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(new Uri(@"sampleImages\berries.jpg", UriKind.Relative));
mycanvas.Background = ib;
and you can now draw on your canvas a line like this.. 现在您可以在画布上画一条这样的线。
line = new Line();
line.Stroke = Brushes.LightSteelBlue;
line.X1 = 1;
line.X2 = 50;
line.Y1 = 1;
line.Y2 = 50;
line.StrokeThickness = 2;
myCanvas.Children.Add(line);
hope it will help you to start.. 希望它能帮助您开始。
You might want to take a look at ZedGraph : 您可能想看看ZedGraph :
ZedGraph is a class library, user control, and web control for .net, written in C#, for drawing 2D Line, Bar, and Pie Charts.
ZedGraph是用C#编写的.net的类库,用户控件和Web控件,用于绘制2D折线图,条形图和饼图。 It features full, detailed customization capabilities, but most options have defaults for ease of use.
它具有完整,详细的自定义功能,但是大多数选项具有默认设置,以易于使用。
I think that you would be re-inventing the wheel if you do it yourself. 我认为,如果您自己动手,将会重新发明轮子。 Also, requirements can change with time, so you might need to add some more items to your graph eventually.
此外,需求可能会随着时间而变化,因此您最终可能需要向图表中添加更多项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.