Using InkCanvas for drawing free hand path is not working in Touch

Santhiya Arulsamy 6 Reputation points
2019-12-31T10:52:10.65+00:00

Hi,
I am using InkCanvas control to draw the path over the image (which is inside the grid control). My requirement is to draw a path using single finger and zoom the image using double finger. But the actual behavior of Inkpresenter is when setting the InkPresenter's InputDeviceType as Mouse or Touch, it doesn't allow to detect the PointerEntered or PointerPressed to perform zoom after draw a path. If we set the InkPresenter's InputDeviceType as None we can use the above events to perform zoom.

For that, I am changing the InkPresenter's InputDeviceType as Mouse or Touch in grid's PointerEntered event and change the InkPresenter's InputDeviceType as None in InkPresenter's StrokeCollected event. This is properly working when i am trying to draw a path using mouse, but it does not work on Touch.

C# - Events

private void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args)

{

canvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.None;

}

private void Grid_PointerEntered(object sender, PointerRoutedEventArgs e)

{

canvas.InkPresenter.InputDeviceTypes =

Windows.UI.Core.CoreInputDeviceTypes.Mouse |
Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;

}

Please find the POC sample.

Sample : https://drive.google.com/open?id=1wT9MvnJyXWR91ifUV3tJZJIaNluhfyK_

It is looking framework level issue. Anyone confirm this.?

Universal Windows Platform (UWP)
{count} vote

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,866 Reputation points
    2020-01-01T08:20:50.247+00:00

    This is properly working when i am trying to draw a path using mouse, but it does not work on Touch.

    It's by design, derive from this document

    A touch point is only detectable if a finger is touching the surface. Whenever a touch action results in a PointerPressed event, that event is immediately preceded by a PointerEntered event, with all the event data being the same information for the two events (same pointer ID, same position, and so on.)

    So, the point is pressed at that time. it does not work like the mouse.(need right click after pointer entered). And it will work when you raise finger and touch again.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.