I have a page that has many UI elements and its scrollable vertical like a Timeline. In the middle I have a pivot that when its gets focus or the mouse pointer enters the scroll
The documentation prescribes that we don't put a Pivot inside a ScrollViewer.
Don't place a Pivot control inside a scroll viewer to avoid conflicts with pivot's scrolling logic.
The PointerWheelChanged doc says:
Specific Windows Runtime controls may have class-based handling for the PointerWheelChanged input event. If so, the control probably has an override for the method OnPointerWheelChanged. Typically the event is marked handled by the class handler, and the PointerWheelChanged event is not raised for handling by any user code handlers on that control. A control might do this in order to support traversal of its child elements by using a pointer wheel action.
A note on the GridView and ListView docs also applies to Pivot
.
The PointerWheelChanged event does not bubble up from a GridView. This means that a control that has a GridView inside of it does not receive mouse wheel change messages if the pointer is over the GridView. For example, if you put a GridView inside of a ScrollViewer, you can't scroll the ScrollViewer with the mouse wheel when the pointer is over the GridView.
I found a solution but I hope there is a better way.
Edit: Changed the division it makes it feel more like the the default scroll.
private void PivotItem_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (-120))
{
// On Mouse Wheel scroll Backward
scrollViewer.ChangeView(null, scrollViewer.VerticalOffset + Window.Current.CoreWindow.Bounds.Height / 7, null, false);
}
if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (120))
{
// On Mouse Wheel scroll Forward
scrollViewer.ChangeView(null,scrollViewer.VerticalOffset - Window.Current.CoreWindow.Bounds.Height / 7, null, false);
}
}