如何向LongListSelector wp7添加Flick手势

时间:2013-04-02 15:53:39

标签: windows-phone-7.1 silverlight-toolkit longlistselector

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

0 个答案:

没有答案