Page 1 of 2

ScrollViewer Custom Manipulation issues

Posted: 05 Dec 2022, 15:42
by CornNieu
Hello Noesis Devs

I'm having a bit of an issue with getting manipulations to work. Namely that "ManipulationCompleted" Never gets called no matter what i try, and i got so far by overriding the ScrollViewer's Manipulation methods. As it apparantly cancels the handle after "ManipulationStarting". Is there a way to work around this, or this just a limit of Xaml/WPF?

For More Context:
I'm trying to create smooth content scroller, that handles both manipulation on the scrollviewer as input on the content itself.

Thank you in advance,
Cornee Nieuwenhuis

Re: ScrollViewer Custom Manipulation issues

Posted: 07 Dec 2022, 01:42
by jsantos
Just a quick question, to clarify, are you able to solve this in WPF and not in Noesis or this is a common question for both.

Re: ScrollViewer Custom Manipulation issues

Posted: 07 Dec 2022, 16:27
by CornNieu
Can't solve it with just WPF as that doesn't give a smooth transition between Content inside the ScrollViewer.

Otherwise you could just have a "StackPanel" inside a "ScrollViewer", but this snaps instantly between content.

Re: ScrollViewer Custom Manipulation issues

Posted: 12 Dec 2022, 18:31
by sfernandez
Hello CornNieu, maybe I'm missing something but our ScrollViewer implements by default a smooth scroll of the content when using touch, it just needs to have the PanningMode set to something different than "None", otherwise manipulations are disabled. Can you check that?

Re: ScrollViewer Custom Manipulation issues

Posted: 22 Dec 2022, 16:13
by CornNieu
A bit late of a reply, but unless i implemented it wrong.
But this makes the slider fully smooth, while we want it to stop per content (smoothly). Instead of it just scrolling over content smoothly

Re: ScrollViewer Custom Manipulation issues

Posted: 05 Jan 2023, 14:04
by sfernandez
If you are inheriting from ScrollViewer you can start by checking if IsManipulationEnabled is set to true (default ScrollViewer implementation sets it to true if PanningMode is not 'None'). This is necessary to receive manipulation events.

Then override OnManipulationStarting, set e.handled to true and indicate the e.manipulationContainer (usually the ScrollViewer itself) and the e.mode to TranslateY or what you need.
Next override OnManipulationStarted to capture the touch while dragging, and OnManipulationDelta to update the scroll info:
IScrollInfo* scrollInfo = GetScrollInfo();
float vScroll = scrollInfo->GetVerticalOffset();
scrollInfo->SetVerticalOffset(vOffset - e.deltaManipulation.translation.y * GetPanningRatio());
When inertia is started you can release the touch capture and wait until the manipulation completes.

Could you try that?

Re: ScrollViewer Custom Manipulation issues

Posted: 10 Jan 2023, 14:31
by CornNieu
Thank you for the Reply!

I have tried this but unfortunatly the "GetScrollInfo" method is inaccesible to the inherited class.
Everything else seems to be fine. The same happens as before, can't set the offset.

Re: ScrollViewer Custom Manipulation issues

Posted: 10 Jan 2023, 18:19
by sfernandez
ScrollViewer defines the GetScrollInfo() method as protected, so inheritors can use it. Aren't you inheriting from the ScrollViewer class?

Re: ScrollViewer Custom Manipulation issues

Posted: 11 Jan 2023, 10:00
by CornNieu
Hmm, strange. Has there been an update that changes it to protected, as we are working on quite an older version of noesis

Re: ScrollViewer Custom Manipulation issues

Posted: 11 Jan 2023, 12:23
by CornNieu
It indeed seems to be moved to protected on update 3.1.1, so we'll be looking into updating.
So i'll come back to this whenever we get the time to update Noesis.