0

我有一个 LongListSelector,我想给它添加一个 Flick 手势。我想模仿 iOS 滑动删除操作。

我只设法将 Flick 事件添加到整个 LongListSelector,但我无法获得事件发生的项目。

更新

如果有人需要,我是这样做的:

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="dataTemplate" >
        <Grid x:Name="Main" Margin="0,0,0,5" VerticalAlignment="Center" Tag="{Binding}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <toolkit:GestureService.GestureListener>
                <toolkit:GestureListener Flick="GestureListener_Flick"/>
            </toolkit:GestureService.GestureListener>

            <StackPanel Orientation="Horizontal" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,0">
                    <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center">
                        <TextBlock Text="{Binding name}"  TextTrimming="WordEllipsis" Style="{StaticResource PhoneTextNormalStyle}" FontSize="28" HorizontalAlignment="Stretch"/>
                        <TextBlock Text="{Binding description}" MaxWidth="420" TextWrapping="Wrap" Margin="12,0" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Stretch"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <StackPanel Grid.Column="1" x:Name="LeftPanel" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Name="deleteBtn" Visibility="{Binding showDelete, Converter={StaticResource VisibilityConverter}}" Content="Delete" HorizontalAlignment="Right" VerticalAlignment="Center"/>
            </StackPanel>
        </Grid>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

<toolkit:LongListSelector Grid.Row="0" HorizontalAlignment="Stretch" x:Name="data" Background="Transparent"
    GroupHeaderTemplate="{StaticResource groupHeader}"
    GroupItemTemplate="{StaticResource itemHeader}"
    ItemTemplate="{StaticResource meetingItemTemplate}">
</toolkit:LongListSelector>

并在代码中将 LongListSelector 绑定到您想要的任何内容。

4

0 回答 0