我正在尝试使用Windows 10移动(UW)应用中的ManipulationStarted和ManipulationDelta事件来实现手势识别。但是有一个问题 - 它们不会发射。
问题很可能是我的过度复杂的xaml视图(我在ListView中有HorizontalyScrollable GridView - 并且要启用垂直滚动它全部打包在ScrollViewer中)。但我尝试将这些事件添加到所有容器中,但它们仍然没有触发。
有没有人知道/知道任何溶剂?下面是我的xaml页面树:
<ScrollViewer Grid.Row="2" x:Name="SubscribersView" ManipulationStarted="SubscribersView_ManipulationStarted" ManipulationDelta="SubscribersView_ManipulationDelta">
(......)
<ListView
Margin="0"
Grid.Row="0"
SelectionMode="None"
IsItemClickEnabled="True"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.VerticalScrollMode="Disabled"
HorizontalAlignment="Stretch" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
(......)
<GridView Grid.Row="1"
HorizontalAlignment="Stretch"
Margin="-10"
SelectionMode="None"
IsItemClickEnabled="True"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Visible">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
答案 0 :(得分:0)
对于您尝试处理操作事件的ScrollViewer
,请将ManipulationMode设置为All - 或者根据需要设置。
了解更多:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.manipulationmode
答案 1 :(得分:0)
我找到了一个解决方案 - 我使用了scrollVwer的ViewChanged:下面是解决方案
private void SubscribersView_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
var sv = sender as ScrollViewer;
var verticalOffset = sv.VerticalOffset;
var minVerticalOffset = sv.ExtentHeight - sv.ViewportHeight;
var maxVerticalOffset = sv.ScrollableHeight;
if (maxVerticalOffset < 0 || verticalOffset == maxVerticalOffset || minVerticalOffset <= 0 || verticalOffset <= 0)
{
//reached top or bottom
return;
}
if (verticalOffset > previousVerticalOffset)
{
//Scroll down
if (!popularHidden)
{
MainImageSlideOut.Begin();
popularHidden = true;
}
}
else
{
//Scroll up
if (popularHidden)
{
MainImageSlideIn.Begin();
popularHidden = false;
}
}
previousVerticalOffset = verticalOffset;
}