实施项目列表并进行多项选择 [英] Implement items list with multiple selection

查看:113
本文介绍了实施项目列表并进行多项选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的WP8应用程序中,我想实现与标准邮件应用程序中非常相似的功能-用户可以从列表中选择多个项目的功能.我提供了一些屏幕快照来说明这种行为:

In my WP8 application I would like to implement a functionality that is very similar to what is present in standard mail app - an ability for user to select multiple items from list. I've provided some screenshots to illustrate this behavior:

正常状态:

Normal state:

用户点击项目的左上角,它变为蓝色:

User taps item's left corner and it becomes blue:

已选择项目

Item is selected

我的问题是,这种多重选择功能是否是某些容器控件的标准选项,或者我是否应该进行一些自定义编程以实现此目的?在后一种情况下,您将采用哪种最佳方法来实现此目标,请分享您的想法.

My question is if this multiple selection ability is a standard option for some container control or if I should do some custom programming to achieve this? In the latter case, what's the best approach you'd take to implement this, please share your thoughts.

推荐答案

对于WP8多选,您需要使用 Windows Phone工具包的LongListMultiSelector.

For WP8 Multi-Selection you'll need to use the Windows Phone Toolkit's LongListMultiSelector.

您可以在此处找到有关如何使用LongListMultiSelector的代码示例.并此处以获取后面的代码).以下是相关的XAML代码段:

You can find code samples on how to use LongListMultiSelector here (and here for the code behind). Here are the relevant XAML code snippets:

    <phone:PivotItem x:Name="BuddiesPivotItem" Header="Std longlistmultiselector">
        <toolkit:LongListMultiSelector x:Name="buddies" Background="Transparent"
                Margin="0,-8,0,0"
                ItemsSource="{StaticResource buddies}"
                LayoutMode="List"
                IsGroupingEnabled="True"
                HideEmptyGroups="True"
                JumpListStyle="{StaticResource BuddiesJumpListStyle}"
                GroupHeaderTemplate="{StaticResource BuddiesGroupHeaderTemplate}"
                ItemTemplate="{StaticResource BuddiesItemTemplate}"
    />
    </phone:PivotItem>

    <phone:PivotItem x:Name="GridModeItem" Header="Grid mode">
        <toolkit:LongListMultiSelector x:Name="GridSelector"
               ItemsSource="{StaticResource PicturesAlbum}"
               IsGroupingEnabled="False"
               GridCellSize="210,180"
               LayoutMode="Grid"
               HideEmptyGroups="True"
               ItemTemplate="{StaticResource PictureItemTemplate}"
               IsSelectionEnabledChanged="OnGridSelectorIsSelectionEnabledChanged"
               SelectionChanged="OnGridSelectorSelectionChanged"
        />
    </phone:PivotItem>

运行这些代码段时,您会看到以下内容:

When you run these code snippet you can see the following:

您可以详细了解Windows Phone 8工具包

You can read more about the Windows Phone 8 Toolkit here.

这篇关于实施项目列表并进行多项选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆