在gridview中捕获PointerWheelChanged事件

时间:2017-07-12 17:06:27

标签: c# uwp

我有一个gridview;如果没有填充我可以使用pointerwheelchanged事件,但是,如果我实现gridview,例如,1000项,所以我可以使用gridview scrollview,指针roundchanged不再被截获,因为现在有“前”的项目。 即使我使用例如100个项目实现gridview后,如何使用pointerwheelchanged?

没有项目工作:

    <StackPanel Orientation="Vertical">
        <GridView x:Name="GridViewItems" HorizontalAlignment="Left" Height="338" VerticalAlignment="Top" Width="583" PointerWheelChanged="vivvio_PointerWheelChanged" Background="#FF86C441">

        </GridView>
        <TextBox x:Name="txtScroll" HorizontalAlignment="Left" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="102" Width="583"/>
    </StackPanel>

    int cont = 1;
    private void GridViewItems_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
    {
        txtScroll.Text = cont.ToString();
        cont += 1;
    }

项目不起作用:

<StackPanel Orientation="Vertical">
    <GridView x:Name="GridViewItems" HorizontalAlignment="Left" Height="338" VerticalAlignment="Top" Width="583" PointerWheelChanged="vivvio_PointerWheelChanged" Background="#FF86C441">
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
        <GridViewItem FontSize="48" Content="Item"/>
    </GridView>
    <TextBox x:Name="txtScroll" HorizontalAlignment="Left" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="102" Width="583"/>
</StackPanel>

int cont = 1;
private void GridViewItems_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
    txtScroll.Text = cont.ToString();
    cont += 1;
}

感谢您的帮助!!

1 个答案:

答案 0 :(得分:0)

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }
    int cont = 1;
    private void GridViewItems_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
    {
        txtScroll.Text = cont.ToString();
        cont += 1;
    }
}