Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement items list with multiple selection

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:
Normal state

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

Item is selected
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.

like image 301
src091 Avatar asked Dec 12 '22 19:12

src091


1 Answers

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

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:

LongListMutliSelector print screen

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

like image 196
JustinAngel Avatar answered Dec 29 '22 17:12

JustinAngel