Hello All, I have a wpf ink canvas. i need to draw a line that connects two pints on it. The scenario is that when i click on inkcanvas, my line should start and at mousedown event or so, that staright line should get created. please help. thank you.

Point position = e.GetPosition(this);
double x = position.X;
double y = position.Y;
Line linetodraw = new Line();

linetodraw.X1 = 0;
linetodraw.Y1 = 0;
linetodraw.X2 = x;
linetodraw.Y2 = y;
linetodraw.StrokeThickness = 1;
linetodraw.Stroke = new SolidColorBrush(Colors.Black);
inkCanvas1.Children.Add(linetodraw);

Well this the code you can use to insert lines in your canvas, you can modify it to draw lines on mouse up and down events.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.