windows-8 - ScrollViewer 和处理子元素上的操作事件

标签 windows-8 windows-runtime windows-store-apps winrt-xaml

我使用 C#/XAML 创建了一个 Windows 8 Store 应用程序。我的界面包含一个可滚动列表,它使用 ScrollViewer 呈现.我希望能够处理列表中元素的操作事件,但是,设置 ManipulationMode除了 None在列表元素上导致我的列表不再滚动。

这是 UI 的简化版本:

<ScrollViewer>
  <Border/> <!-- these contain child content -->
  <Border/>
  <Border/>
  <!-- Set ManipulationMode on an element in order to receive manipulation events -->
  <!-- This causes the scroll viewer to stop working! -->
  <Border ManipulationMode="All"
          ManipulationDelta="..."/>
  <Border/>
  <Border/>
</ScrollViewer>

我了解 WinRT ScrollViewer使用特殊ManipulationModeSystem出于性能原因,但我想要一个垂直滚动列表,其中包含响应水平操作/手势的元素。谁能想到一个创造性的解决方法,使这成为可能?

最佳答案

可能是很长时间,但没有找到任何好的解决方案。我只是很容易地实现了我想要的。

public MovableGrid()
        {
            ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.System;
            AddHandler(ManipulationDeltaEvent, new ManipulationDeltaEventHandler(UIElement_OnManipulationDelta), true);
            AddHandler(ManipulationCompletedEvent, new ManipulationCompletedEventHandler(UIElement_OnManipulationCompleted), true);
        }

我希望我的 MovableGrid 在 X 轴上移动,并且我有我想用 scrollviewer 滚动的 MovableGrid 列表。这足以做到这一点。

关于windows-8 - ScrollViewer 和处理子元素上的操作事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12636216/

相关文章:

c# - 测试设备是否始终在线/始终连接 (AOAC) 或支持连接待机?

winforms - Windows 8 密码框占位符

electron - 将使用 Electron 构建的 APPX 发布到 Windows Store 和 Desktop Bridge 程序

c# - 后退按钮专注于列表操作

windows-8 - 文本服务和输入法编辑器有什么区别?

Android Studio,清除只读状态不起作用

c# - 在 sqlite 中更新数据

c# - 在 Windows Phone 8.1 上使用 Lumia Imaging SDK 的 CameraPreviewImageSource 和 WinRT 时如何设置相机属性

c# - ListViewItem IsSelected Binding - 适用于 WPF,但不适用于 WinRT

c# - 无法将网格从先前值动画化为新值