我有一个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绑定到您想要的任何内容。