WP7 ListBox如何让用户订购商品

时间:2010-11-21 11:17:44

标签: c# .net silverlight windows-phone-7

场景:使用MVVM的Windows Phone 7应用程序。我有一个ListBox,它绑定到我的ViewModel的一组项目。此视图的主要用途是允许用户根据自己的喜好重新排序项目。

如何在WP7中实现这一点?我想这样做的方法是简单地允许用户将项目拖动到他想要的位置。这种手势有内置支持吗? (我一直都找不到)。

3 个答案:

答案 0 :(得分:3)

您可以在项目中加入Silverlight for Windows Phone Toolkit,然后使用GestureListener收听DragStartedDragDeltaDragComplete个事件。

答案 1 :(得分:1)

如AnthonyWJones所述,GesureListener可能正是您所寻找的。我只是想补充一点,您可以将FluidMoveBehavior用于列表,以便在项目顺序更改时项目可以平滑地设置动画。在我看来,它提供了更好的用户体验。

流畅的移动行为很简单,只需“插入”现有列表,如下所示:

<Style TargetType="ListBox" x:Key="FluidListBox">
    <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate>
                <StackPanel>
                    <i:Interaction.Behaviors>
                        <ei:FluidMoveBehavior AppliesTo="Children" Tag="DataContext">
                            <ei:FluidMoveBehavior.EaseY>
                                <BackEase EasingMode="EaseInOut" Amplitude="0.5"/>
                            </ei:FluidMoveBehavior.EaseY>
                            <ei:FluidMoveBehavior.EaseX>
                                <BackEase EasingMode="EaseInOut" Amplitude="0.5"/>
                            </ei:FluidMoveBehavior.EaseX>
                        </ei:FluidMoveBehavior>
                    </i:Interaction.Behaviors>
                </StackPanel>
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>
</Style>

答案 2 :(得分:1)

此解决方案非常有效

http://blogs.msdn.com/b/jasongin/archive/2011/01/03/wp7-reorderlistbox-improvements-rearrange-animations-and-more.aspx

这是一个控件,只需放入您的应用程序,您只需启用拖动控制柄并在ListBox中移动项目。

相关问题