Enable Mouse Scrolling While Maintaining Ability to Touch Select Items
windows-8, windows-runtime, winrt-xaml
Solution
I don't think your scenario is possible. The SV with the grid inside it is the problem. The MSDN docs say that the GridView prevents the PointerWheelChanged event from bubbling up:
See the GridView docs:
Caution 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.
Problem
I'm using a GridView to display a list of items. I need the ability to be able to use the mouse scroll wheel to scroll in the page where the GridView is contained. This is easily achievable by overriding the template of the GridView ``` <GridView.Template> <ControlTemplate> <ItemsPresenter /> </ControlTemplate> </GridView.Template> ``` However, I also need the items to be selectable from a touch device. This is usually done by flicking an item downwards after which it would be selected. After applying the above template override the touch selection mechanism breaks. I went into Blend and started looking at the default template for the GridView which can be seen below ``` <ControlTemplate TargetType="GridView"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> <ScrollViewer x:Name="ScrollViewer" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}" IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" TabNavigation="{TemplateBinding TabNavigation}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"> <ItemsPresenter HeaderTemplate="{TemplateBinding HeaderTemplate}" Header="{TemplateBinding Header}" HeaderTransitions="{TemplateBinding HeaderTransitions}" Padding="{TemplateBinding Padding}" /> </ScrollViewer> </Border> </ControlTemplate> ``` If I remove the ScrollViewer or disable the horizontal scrolling part in any way then the touch selection stops working. How can I enable both mouse scrolling and touch selection at the same time? And just to clarify, I don't need the actions to happen simultaneously. Both just need to work separately on the same page for the same GridView.