Windows 8商店应用.ListView.触摸项目滚动和指针*事件
本文关键字:滚动 指针 事件 项目 触摸 应用 ListView Windows | 更新日期: 2023-09-27 18:07:33
我有listView和items:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView x:Name="_listView" SelectionMode="None" VerticalAlignment="Center"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollMode="Enabled" IsTapEnabled="False" IsHoldingEnabled="False" IsSwipeEnabled="False">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</Grid>
public MainPage()
{
this.InitializeComponent();
for (int i = 0; i < 30; i++)
{
Border _border = new Border();
_border.Width = 400;
_border.Height = 300;
_border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
_border.PointerPressed += _border_PointerPressed;
_border.PointerReleased += _border_PointerReleased;
_border.PointerExited += _border_PointerExited;
_border.PointerEntered += _border_PointerEntered;
//_border.ManipulationMode = ManipulationModes.All;
_listView.Items.Add(_border);
}
}
void _border_PointerEntered(object sender, PointerRoutedEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
}
void _border_PointerExited(object sender, PointerRoutedEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
}
void _border_PointerReleased(object sender, PointerRoutedEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 255, 255));
}
void _border_PointerPressed(object sender, PointerRoutedEventArgs e)
{
Border border = sender as Border;
border.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 0));
}
当我尝试在项目中使用触摸- PointerExited, PointerReleased, PointerMoved -不触发。如果我取消注释_border。operationmode = operationmodes。触发了所有事件,但滚动不起作用:(。请告诉我,如果可能的话,如何实现触发这些事件和滚动?谢谢你。
尝试使用ManipulationModes.All|ManipulationModes.System