How about using a polyline?
Here xaml:
<Window
x:Class="CursorLine.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
>
<Canvas x:Name="canvas" Background="#00FFFFFF" MouseMove="Canvas_MouseMove">
<Polyline x:Name="polyline" Stroke="DarkGreen" StrokeThickness="3"/>
</Canvas>
</Window>
Here is the code behind:
private void Canvas_MouseMove(object sender, MouseEventArgs e)
{
polyline.Points.Add(e.GetPosition(canvas));
}
source
share