I am using a gridview to display a list of items. I need the ability to use the mouse scroll wheel to scroll on the page that contains the GridView. This is easily achieved by overriding the GridView template.
<GridView.Template> <ControlTemplate> <ItemsPresenter /> </ControlTemplate> </GridView.Template>
However, I also need elements that can be selected from the touch device. This is usually done by clicking the item down, after which it will be selected. After applying the above template, the redefinition of the touch selection mechanism breaks.
I went to 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 part of the scroll in any way, then the touch selection will stop working.
How can I turn on mouse scrolling and touch selection at the same time?
And just in order to clarify, I do not need actions that must occur simultaneously. Both just need to work separately on the same page for the same GridView.
source share