我使用 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
使用特殊ManipulationMode
的 System
出于性能原因,但我想要一个垂直滚动列表,其中包含响应水平操作/手势的元素。谁能想到一个创造性的解决方法,使这成为可能?
最佳答案
可能是很长时间,但没有找到任何好的解决方案。我只是很容易地实现了我想要的。
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/