I have a Canvas (not InkCanvas) inside a Scrollviewer. Both are not created in XAML but in code behind. I want to draw lines on my Canvas with Pen and Mouse input, everything works just fine but now I tested the whole thing with a pen as input device and the Scrollviewer seems to recognize it as touch input because the whole thing starts scrolling.
My question is: Is it possible to tell the Scrollviewer to ignore all inputs from a device type? Because it also seems like the Scrollviewer is 'eating' the events which should be fired from the Canvas.
Here my Scrollviewer init:
private void SetUpScrollViewer()
{
scroll = new ScrollViewer();
scroll.VerticalScrollMode = ScrollMode.Auto;
scroll.HorizontalScrollMode = ScrollMode.Auto;
scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
scroll.ZoomMode = ZoomMode.Enabled;
scroll.ManipulationMode = ManipulationModes.System;
scroll.HorizontalAlignment = HorizontalAlignment.Left;
scroll.VerticalAlignment = VerticalAlignment.Top;
scroll.IsZoomInertiaEnabled = false;
scroll.MinZoomFactor = 1;
scroll.MaxZoomFactor = 5;
}
Those are the events I use in my Canvas:
public void EnableDrawingOnCanvas(Canvas canvas)
{
//Adding the needed event handler.
canvas.PointerPressed += Canvas_PointerPressed;
canvas.PointerMoved += Canvas_PointerMoved;
canvas.PointerReleased += Canvas_PointerReleased;
canvas.PointerExited += Canvas_PointerExited;
}
And those events all check if the input device is everything but touch like this
if (e.Pointer.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch){...}
But with those Events I can only check the input device for my Canvas and if I add a Event to the Scrollviewer it won't get passed to the Canvas afaik.