【发布时间】:2016-01-01 15:27:57
【问题描述】:
假设我有以下 XAML:
<Grid ManipulationMode="TranslateY" ManipulationDelta="Grid_ManipulationDelta">
<ScrollViewer HorizontalScrollMode="Enabled" VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden">
<StackPanel Orientation="Horizontal">
<Rectangle Width="100" Height="100" Fill="Red" />
<Rectangle Width="100" Height="100" Fill="Blue" />
<Rectangle Width="100" Height="100" Fill="Red" />
<Rectangle Width="100" Height="100" Fill="Blue" />
<Rectangle Width="100" Height="100" Fill="Red" />
<Rectangle Width="100" Height="100" Fill="Blue" />
<Rectangle Width="100" Height="100" Fill="Red" />
<Rectangle Width="100" Height="100" Fill="Blue" />
</StackPanel>
</ScrollViewer>
</Grid>
(StackPanel 只是任意内容。)
我希望 Grid 只处理 TranslateY 操作事件,而 ScrollViewer 只处理水平滚动;但是,即使操作是垂直的而不是水平的,ScrollViewer 也会优先。 Grid 从不接收 ManipulationDelta 事件,除非我禁用 ScrollViewer 上的滚动,这显然不是我想要的。
这是否与 ScrollViewer 的直接操作事件的“神奇”行为有关?我也尝试过“rails”设置的不同组合(即在 ScrollViewer 上将 Grid 的 ManipulationMode 设置为 TranslateRailsY 并将 IsHorizontalRailEnabled 设置为 true),但它仍然不起作用。
【问题讨论】:
标签: c# xaml uwp windows-runtime winrt-xaml