In my Windows Store App (c#, xaml) I have ScrollViewer, when I zoom in it and trying to scroll - the ScrollViewer fired event PointerCaptureLost and I can't handle any pointers events anymore.
Why it happens, and how I can handle pointers events (for example PointerMoved) during scroll ScrollViewer?
Looks like it may not be possible without some serious hacks.
What's happening is that whenever there is "a touch event that causes the FlipView to animate ", the thing that is causing that animation is the ScrollViewer built into the FlipView, used for flipping. The scrollviewer takes away pointer input until the panning has completed and it cannot be taken back. This is a feature called DirectManipulation which is now processing input on a separate thread to give the smoothest possible panning handling. (Pointer events fire in the UI Thread)*
in http://social.msdn.microsoft.com/Forums/windowsapps/en-US/1e6732d3-0457-4ddc-b762-963ab974491c/pointerreleased-and-flipview
Related
I want to enable just two finger scrolling. I am developing uwp application on windows 10.How can I prevent to one finger scrolling for listview control in uwp?
Bests
You could probably do that, but I won't help you since that would be an evil feature that would confuse the users of your app. Instead, you should consider alternative solutions to whatever you'd like to happen when users use a single finger in a ScrollViewer.
Note that you're essentially trying to change how the ScrollViewer in the ListView template behaves. In most cases, you do that when you want to drag an item out of a list. Most people either handle the press and hold (aka long holding - the Holding event) or a cross-drag (dragging perpendicular to the ScrollViewer panning direction) and call ScrollViewer.CancelDirectManipulations() to stop panning and handle drag & drop instead.
If you just want a single finger panning to stop working - then you should not do that.
I have a custom ZoomBox control based on ScrollableControl which controls its scrollbars through AutoscrollMinSize property.
I would like to be able to handle WM_MOUSEWHEEL events to adjust control's Zoom.
I made necessary steps to make sure that the control receives the mouse events even when it is not in focus, by filtering them on the parent form.
It seems though that the events only reach the OnMouseWheel method if the control does not have its scrollbars active. If it does, it appears that the mousewheel events are being redirected to the scrollbars which handle them (by scrolling).
I would like the scrollbars to be there but only be controlled in a "traditional way", i.e. by dragging the slider or clicking on arrows etc. and handle the wheel myself. Is it possible to achieve that?
Inherit from the ScrollableControl in question and override OnMouseWheel(). In that method don't call base.OnMouseWheel().
As far as I can tell there's no other way to stop ScrollableControl from scrolling if the scroll bars are present.
A side effect is that you will no longer get MouseWheel events. Fixing that is another question. Conceptually you want to call base.base.OnMouseWheel().
I'm using a Windows Phone 8.1 project and have a ScrollViewer in my XAML.
Is there an event which will fire when the ScrollViewer start scrolling? Or anyway to trigger code when ScrollViewer start scrolling?
Try ViewChanging and ViewChanged events of ScrollViewer.
Note that these events will be called multiple times during a touch manipulation. You will need to rely on IsIntermediate (in ScrollViewerViewChangedEventArgs) or IsInertial (in ScrollViewerViewChangingEventArgs) to call your code accordingly.
Update
If you want to know when a touch happens immediately I'd give the ScrollViewer's direct child, for example, a StackPanel a transparent background and then subscribe to its PointerEntered event.
In my Windows Phone 8 application I am trying to implement a custom control that behaves like the built-in calendar control which displays the current date above the scrollable content (daily views). Initially I have tried to use the LongListSelector control (which gives me the hierarchical view), but I am not able to determine the scroll position and therefore cannot update the header (the date in the case of the calendar control).
So I switched to using a ScrollViewer control which contains a StackPanel with different controls inside.
Whenever the user scrolls the content I would like to be notified so I can update the UI relative to the content being shown. However, the ScrollViewer doesn't have any explicit scrolling events.
I have tried to use the LayoutUpdated event (which seems to get called frequently enough for my purposes), but when I then update the UI in the event handler another LayoutUpdated event is raised and an infinite loop is created.
How can I update the UI based on the scroll position?
I have no idea, But check this links, this may help.
Get scroll event for ScrollViewer on Windows Phone
http://social.msdn.microsoft.com/Forums/silverlight/en-US/b1cdf697-ed37-4d3a-9f3c-46338bdc92b4/how-to-get-a-scroll-event-from-a-scrollviewer?forum=silverlightbugs
Is it possible to get notification of any MouseMove event, even those marked as handled? I have the following Xaml:
<Grid x:Name="ParentContainer">
<ScrollViewer>
...
</ScrollViewer>
</Grid>
My goal is to get all MouseMove events on the ScrollViewer, or something reasonably close to it like the ParentContainer, without resorting to setting ManipulationMode="Control" on the ScrollViewer for the best possible performance.
Handling MouseMove on the ParentContainer (or the ScrollViewer) works when ManipulationMode="Control" is set on the ScrollViewer, but not when ManipulationMode="System". It sounds like to improve performance in Mango, the ScrollViewer started swallowing MouseMove events to improve performance. However, I'd expect to be able to get those handled events as follows:
ParentContainer.AddHandler(???.MouseMoveEvent, MyMouseMoveHandler, true);
In Silverlight or WPF I would expect that code to route all mouse events to MyMouseMoveHandler, even handled events. Unfortunately I can't find a static definition of MouseMoveEvent to pass to AddHandler.
Has anyone had success using AddHandler with MouseMoveEvent in WP7?
My last resort may be to add an overlay on top of the ScrollViewer with Background="Transparent" that would capture all Mouse events, but not mark them as handled and see if they propagate down to the ScrollViewer.
In Windows Phone OS 7.1, changes were made to specifically improve the scrolling of the ScrollViewer control. To do this they had to move the listening of the touch gestures to a separate thread. This meant an architecture level change for how the control listened to the gestures. With Windows Phone 7.1, there is now 3 threads responsible for scrolling the ScrollViewer: one for input, one for animations, and one for creating new items.
As a result of this change, you will not be able to capture the handled mouse events from this control, unless you set the ManipulationMode to Control. As you stated in your question though, this will disable the changes which were made to improve scrolling performance.
You cannot expect that a solution which will work for non-Windows Phone Silverlight will work in this case because the underlying architecture is fundamentally different on the phone starting with Windows Phone 7.1.
Here is Microsoft's blog post regarding the change: http://blogs.msdn.com/b/slmperf/archive/2011/06/02/listbox-scrollviewer-performance-improvement-for-mango-and-how-it-impacts-your-existing-application.aspx
Instead of looking for mouse events it's possible to use the Touch.FrameReported event to receive notification any time the user touches the screen. This event reports for ScrollViewers where the ManipulationMode == System. This seems to be a suitable workaround for a global MouseMove handler on WP7.
http://msdn.microsoft.com/en-us/library/system.windows.input.touch.framereported(v=vs.95).aspx