Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wp7 horizontal swipe selection

I'm looking for a control that allows me to swipe through a list of items. Swiping horizontally would move between the next and previous items. The control would also ensure the selected item is moved to the center when not being manipulated. This control will only take up half of the page and I'd like the options to the left and right to be visible and wrap around.

Like so

  <-->
*][**][*

So my question is, does a control like this already exists and if so what is it called?

like image 881
Daniel Little Avatar asked Aug 15 '11 11:08

Daniel Little


2 Answers

This is super easy if you use the GestureService from the Silverlight Toolkit. Simply implement a handler for the Flick event, and analyse the directory and velocity.

XAML

<toolkit:GestureService.GestureListener>
    <toolkit:GestureListener Flick="GestureListener_Flick" />
</toolkit:GestureService.GestureListener>

C#

private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
    if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
    {
        if (e.HorizontalVelocity < 0)
        {
            // flick right
        }
        else
        {
            // flick left
        }
    }
    else
    {
        if (e.VerticalVelocity < 0)
        {
            // flick up
        }
        else
        {
            // flick down
        }
    }
}
like image 62
Claus Jørgensen Avatar answered Nov 07 '22 12:11

Claus Jørgensen


There is no standard control which meets this description.

If you really want this then you'll have to create it yourself.

like image 37
Matt Lacey Avatar answered Nov 07 '22 11:11

Matt Lacey