Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

the LonglistmultiSelector is missing in my toolkit..

if i run the following code:

<toolkit:LongListMultiSelector x:Name="EmailList" 
                                                Margin="0,14,-12,0"
                                                ItemsSource="{StaticResource EmailCollection}"
                                                LayoutMode="List"
                                                SelectionChanged="OnEmailListSelectionChanged"
                                                          IsSelectionEnabledChanged="OnEmailListIsSelectionEnabledChanged"
                                                ItemTemplate="{StaticResource EmailItemTemplate}"
                                                ItemInfoTemplate="{StaticResource EmailItemInfoTemplate}"
            />

if get the Error: Error 1 The name "LongListMultiSelector" does not exist in the namespace "clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top