@HoneyBee , Based on my further research, I suggest that you could create stroke data from mouse input on a Canvas overlay over an InkCanvas.
Here is a code example you could refer to.
xaml:
<Grid>
<InkCanvas x:Name="inkCanvas" IsHitTestVisible="False"/>
<Canvas Background="Transparent"
MouseLeftButtonDown="Canvas_MouseLeftButtonDown"
MouseLeftButtonUp="Canvas_MouseLeftButtonUp"
MouseMove="Canvas_MouseMove"/>
</Grid>
c# Code:
private Stroke stroke;
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var pos = e.GetPosition(inkCanvas);
var points = new StylusPointCollection
{
new StylusPoint(pos.X, pos.Y)
};
stroke = new Stroke(points, inkCanvas.DefaultDrawingAttributes);
inkCanvas.Strokes.Add(stroke);
}
private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
stroke = null;
}
private void Canvas_MouseMove(object sender, MouseEventArgs e)
{
if (stroke != null)
{
var pos = e.GetPosition(inkCanvas);
stroke.StylusPoints.Add(new StylusPoint(pos.X, pos.Y));
}
}
Hope this could hepl you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.