wp7 horizontal swipe selection

只谈情不闲聊 提交于 2019-12-30 06:53:30

问题


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?


回答1:


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



回答2:


There is no standard control which meets this description.

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



来源:https://stackoverflow.com/questions/7064430/wp7-horizontal-swipe-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!