简体   繁体   中英

LongListMultiSelector equivalent in windows phone 8.1 universal app

What is the equivalent of the LongListMultiSelector in windows phone when created as a universal app?

All I want to do is provide checkboxes when I tap on the left inside of a list but I can't figure out to do it.

I've tried using the ListView, but that either displays the checkboxes all the time (SelectionMode=Multiple) or never (SelectionMode=None or Single) but this is not what I want.

Should I be handling this differently?

What I have is a bunch of locations in a list and in my command bar, I've got the add button, but I want to let the user select one or more locations when they tap on the left inside of an item as I did when using the LongListMultiSelector and let them edit (when one is selected) or delete when multiple are selected but when tapped, it should just open the relevant location.

I've recently seen an app where adding works the same but in order to view/edit/delete, the user selects one or more item and the buttons on the command bar change to view (one selected), edit (one selected) and delete (multiple selected) but I'm not sure I like that regarding the "view" option as this requires 2 steps thus preferring the tapping on the left inside to display the checkboxes and provide edit/delete this way.

Thanks

I needed that also in a recent project! Best solution I found was using the MultiSelectListView from the QKit library!

It's up on codedplex here : https://qkit.codeplex.com/

Description of the control:

While the built in ListView control supports multiple selection, the animation to display the CheckBoxes are not pleasant or accurate to the OS. With the MultiSelectListView, the animation and UX is nearly identical to the multiselection lists found in the OS. Not only that, this control allows you to invoke multiselection mode by tapping on the left edge of the item just like in the email app.

This is the bare bones for selecting multiple list items with a checkbox. Basically you can do anything you want with each listbox item. By having data binding to the checkbox and the content of the checkbox.

It's then up to you how to implement the navigation, visibility or contents as you please.

<ListBox x:Name="ListBox1" ItemsSource="{Binding}" SelectionMode="Multiple" >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox x:Name="checkBox"  
                     IsChecked="{Binding MyBindingChecked}" 
                     Content="{Binding MyBindingText}"
                     Checked="Checked_Handler" 
                     Unchecked="Unchecked_Handler" 

Using these methods, you can then implement your navigation etc.

// Handler for checked items.
private void Checked_Handler(object sender, RoutedEventArgs e)
{
    HandleChecked(sender as CheckBox);
}
// Handler for unchecking items.
Private void Unchecked_Handler(object sender, RoutedEventArgs e)
{
    HandleUnchecked(sender as CheckBox);
}
// Handle code for Checked handler.
private void HandleChecked(CheckBox checkBox)
    {// TODO
// Handle code for Unchecked handler.
private void HandleUnchecked(CheckBox checkBox)
    {// TODO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM