gpt4 book ai didi

windows-8 - 在保持触摸选择项目的能力的同时启用鼠标滚动

转载 作者:行者123 更新时间:2023-12-05 01:15:03 24 4
gpt4 key购买 nike

我正在使用 GridView 来显示项目列表。我需要能够使用鼠标滚轮在包含 GridView 的页面中滚动。这很容易通过覆盖 GridView 的模板来实现

<GridView.Template>
<ControlTemplate>
<ItemsPresenter />
</ControlTemplate>
</GridView.Template>

但是,我还需要可以从触摸设备中选择这些项目。这通常是通过向下轻弹一个项目来完成的,然后它就会被选中。应用上述模板覆盖后,触摸选择机制中断。

我进入 Blend 并开始查看 GridView 的默认模板,如下所示
<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>

如果我删除 ScrollViewer 或以任何方式禁用水平滚动部分,则触摸选择将停止工作。

如何同时启用鼠标滚动和触摸选择?

澄清一下,我不需要这些操作同时发生。两者都只需要在同一个 GridView 的同一页面上单独工作。

最佳答案

我不认为你的情况是可能的。带有网格的 SV 是问题所在。 MSDN 文档说 GridView 防止 PointerWheelChanged 事件冒泡:

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.

关于windows-8 - 在保持触摸选择项目的能力的同时启用鼠标滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13845641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com