Xamarin.forms: [Enhancement] Add SelectionMode property to ListView

Created on 6 Feb 2018  Â·  13Comments  Â·  Source: xamarin/Xamarin.Forms

Rationale

Allow customization of the ListView selection mode.

Implementation

Add a new bindable property called SelectionMode:

public class ListView : ...
{
     public ListViewSelectionMode SelectionMode { get; set; }
}
public enum ListViewSelectionMode
{
     None,
     Single
}

The default value of SelectionMode property will be Single to reflect today's selection mode which is single selection.

None will stop the highlight from appearing when a row is tapped.

When SelectionMode property is set to None, tapping/clicking on items in the ListView will no longer select them; the ItemSelected event will not fire, and the value of the SelectedItem property will remain null.

If the SelectedItem property is set when SelectionMode transitions to None, SeletedItem will be set to null and the ItemSelected event will not fire.

When SelectionMode is None, the ItemTapped event will still fire.

Backward Compatibility

It will work 100% on all platforms.

Difficulty: Easy

Android: set listView.ChoiceMode property to ChoiceMode.None or ChoiceMode.Single
iOS: set tableView.AllowsSelection property to false or true
UWP: set listView.SelectionMode property to ListViewSelectionMode.None or ListViewSelectionMode.Single

F100 enhancement âž•

Most helpful comment

SelectionMode=None (tested in UWP and Android) still shows the "select effect" (Tap animation)

All 13 comments

You could improve this idea by allowing the user to select multiple items but I don't know how difficult that would be to implement

@sander1095 Let's not get ahead of ourselves :) You're right, but let's do this in phases maybe, or it will never be done.

Sounds good! :D

This needs more detail about what happens when SelectionMode is set to None. I'd propose the following:

When this property is set to None, tapping/clicking on items in the ListView will no longer select them; the ItemSelected event will not fire, and the value of the SelectedItem property will remain null.

If the SelectedItem property is set when SelectionMode transitions to None, SeletedItem will be set to null and the ItemSelected event will not fire.

When SelectionMode is None, the ItemTapped event will still fire.

@hartez I edited the description. Do we have a 100% green light on this? @jassmith ?

Nope, anything in backlog does not have greenlight. This one isn't on the F100 list either so its unlikely to be bumped out of backlog very quickly as we go through the ones that are marked F100. I will send the issue up the flagpole however and see what shimmies back on down.

@jassmith I don't understand your last sentence.
As someone who wants to become a contributor, it's not clear to me the flow from from a proposed enhancement ticket to one which has been greenlight'ed and it's ready for someone to pickup and be implemented.
Looking at https://github.com/xamarin/Xamarin.Forms/blob/master/CONTRIBUTING.md it talks about "Accepted". But I can't see any "Accepted" tag or project https://github.com/xamarin/Xamarin.Forms/projects

I don't understand your last sentence.

I mean I will raise the enhancement with the PM team to see what they think.

The Contributing.md is WAY out of date. It needs to be updated. Sorry. Use this board: https://github.com/xamarin/Xamarin.Forms/projects/5

Pick anything in the ready for implementation column

@andreinitescu I discussed this briefly with @jassmith and would like this to happen. I've added it to F100 and will move it to Ready to Implement. Are you up for doing the work?

If not I could have a go at it

I'm going to claim this one as no one seems to be actively working on it.

Tizen : set genlist.SelectionMode property to GenlistSelectionMode.None or GenlistSelectionMode.Always

SelectionMode=None (tested in UWP and Android) still shows the "select effect" (Tap animation)

Was this page helpful?
0 / 5 - 0 ratings