I am actually trying to do a graph whit given points, the things is that I donot know how can I drag one of the m to put it into a desired place. If anyone could help me please, I would be so grateful
Drag a point in a WPF diagram?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Sandhiya PriyaRank #26 · 43.2K reputationPosted Jan 2, 2026, 6:14 AM EST
In WPF, points on a graph are not draggable by default. You must handle mouse events and update the point’s position manually.
Simple idea to make a point draggable in WPF:
Draw points using a
Canvas(best for absolute positioning)Capture mouse events (
MouseDown,MouseMove,MouseUp)Update the point’s
Canvas.LeftandCanvas.Topwhile draggingBasic approach:
On
MouseDown? start draggingOn
MouseMove? change the point positionOn
MouseUp? stop draggingExample (Ellipse as a draggable point):
bool isDragging = false; Point mouseOffset; private void Point_MouseDown(object sender, MouseButtonEventArgs e) { isDragging = true; var ellipse = sender as Ellipse; mouseOffset = e.GetPosition(ellipse); ellipse.CaptureMouse(); } private void Point_MouseMove(object sender, MouseEventArgs e) { if (!isDragging) return; var ellipse = sender as Ellipse; var position = e.GetPosition(MyCanvas); Canvas.SetLeft(ellipse, position.X - mouseOffset.X); Canvas.SetTop(ellipse, position.Y - mouseOffset.Y); } private void Point_MouseUp(object sender, MouseButtonEventArgs e) { isDragging = false; var ellipse = sender as Ellipse; ellipse.ReleaseMouseCapture(); }points to remember:
Use
Canvasfor graph plottingEach point (Ellipse) can be dragged independently
Update coordinates to redraw lines if the graph is connected
This is the standard and recommended way to drag graph points in WPF.