0

I have a LongListSelector and I want to add a Flick gesture to it. I want to mimic iOS swipe to delete action.

I only managed to add the Flick event to the whole LongListSelector, but I couldn't get the item the event happend on.

UPDATE

Here's how I managed to do it in case anyone needs it:

<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>

and in the code you bind your LongListSelector to whatever you want.

AboulEinein
  • 1,101
  • 3
  • 13
  • 27
  • Have you tried adding it to the datatemplate? If your datatemplate is some kind of panel, perhaps adding a flick event to it should do the trick. – Igor Ralic Apr 07 '13 at 13:28
  • My DataTemplate contains a Grid, and there's no Flick event for the Grid (nor does the StackPanel contain Flick event) – AboulEinein Apr 07 '13 at 15:12
  • 1
    How about using a gesture service from the Windows Phone toolkit? http://stackoverflow.com/questions/5166172/gestureservice-onflick – Igor Ralic Apr 07 '13 at 16:18
  • Thanks to your help I managed to do it, I updated my question with the solution :) – AboulEinein Apr 09 '13 at 09:20

0 Answers0