I have this code in a Windows 10 UWP application:
MyListView.ManipulationMode = ManipulationModes.TranslateX;
MyListView.ManipulationStarted += (s, e) => x1 = (int)e.Position.X;
MyListView.ManipulationCompleted += (s, e) =>
{
x2 = (int)e.Position.X;
if (x1 > x2)
{
DataController.PaneOpen(false);
};
if (x1 < x2)
{
DataController.PaneOpen(true);
};
};
The ManipulationCompleted
event doesn't work on phone in ListView
. The code inside the handler never gets called.
It's working fine on PC, but doesn't work on phone. I don't understand why.
When a ListView
works on PC, we can scroll it by scrolling the wheel of mouse, but when it works on phone, there is no mouse device connected to a phone, we actually scroll the ListView
through swiping.
A ListView
control contains a ScrollViewer
like this:
I think the problem is with this ScrollViewer
, when it is on PC, it handles Scrolling and Manipulation events separately, but when it is on a phone, it can't differentiate the events of scrolling and manipulation.
In my view, this manipulation event can respond to Mouse device, but not to single finger touch. It is clearer if we test a ListView
on Mobile Emulator and simulator, when you use Single Point Mouse Input
of a phone emulator or Mouse Mode
of simulator, the manipulation events works fine, but when you use Single Point Touch Input
of mobile emulator or Basic Touch Mode
of simulator, it doesn't work. Interesting thing is, the manipulation events actually still works fine on a mobile emulator when we use Multi-Touch Input
. More interesting thing is, the official docs of Using manipulation events says:
If you don't have a touch-screen monitor, you can test your manipulation event code in the simulator using a mouse and mouse wheel interface.
So, it's supposed to work on a real phone. Since I don't have any device by now, I can't tell if it works fine on a real phone, I will update my answer after I test it on device.
But, we can still manipulate a ListView
on a phone by handling the events of Pointer
like this:
<ListView x:Name="MyListView" PointerCanceled="PointerExisted" PointerEntered="PointerEntered" PointerMoved="PointerMoved" PointerExited="PointerExisted">
Tested it, it works fine both on PC and phone.
Update:
Just tested on X1 Carbon, Lumia950, I found that the Manipulation event will be triggered using two fingers, the result is same as it was on mobile emulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With