Question

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.

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!

Was it helpful?

Solution

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..

OTHER TIPS

You might want to take a look at ZedGraph:

ZedGraph is a class library, user control, and web control for .net, written in C#, for drawing 2D Line, Bar, and Pie Charts. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top