Forum Xamarin.Forms

Best method to implement a multi select list?

d_dblud_dblu CAUniversity ✭✭
edited June 2014 in Xamarin.Forms

UPDATE: I think implementing it with a Custom Renderer which customizes ListView is the approach. I'll post back with results.

I'm trying to implement a multi-select list. The list only contains a list of one type of cell. If I'm not mistaken, the ListView only allows for single select and can't be subclassed to override that, and so I'm trying to use the TableView with Intent.Data but the documentation is sparse and I can't really figure out how to. What is the best approach? Should I use a Custom Renderer ?

Best Answers

Answers

  • PatrickKealyPatrickKealy AUMember

    Did u have any luck? Mine is the same problem! please share if u got the multi select list working...

  • d_dblud_dblu CAUniversity ✭✭

    I had to put this aside because I ran out of time but extending the ListView wasn't possible due to the inability to override the single selection behavior it encapsulates. If the accessors change in a future version then it might be possible but otherwise I think mapping a CustomRenderer to a UITableView that is setup for multi-select would be the approach.

    Anyone else get this going?

  • RyanHatfieldOldRyanHatfieldOld USMember, Insider ✭✭✭

    does it have to be a cell?
    You could render a list of buttons, \

    List<Button> buttonList
    

    And set the button command to toggle the colors of the button. when you're done, use some linq on the buttonList and you can figure out what's selected. Something like:

    buttonList.where(b => b.Selected).ToList()
    

    This can all be done in top level Xamarin.Forms without custom renders. If you're interested I could probably whip up an example of what I mean. I've done it in a recent project (Podio integration) but it's waaaaay too involved to dig out. I'd rather make something clean from scratch.

  • d_dblud_dblu CAUniversity ✭✭
    edited July 2014

    That sounds way easier, but I thought that you have to use cells with the list. Also are there any performance issues? If it isn't a cell how is the queue/dequeue reusable cell mechanism working? I'd be interested to see the example. If it works fine I'd be pretty happy with this.

  • PatrickKealyPatrickKealy AUMember

    This is simply great and surely helpful for someone like me looking for a quick alternative to implement a multiselect list. Thanks for support and time.

Sign In or Register to comment.