简体   繁体   中英

Windows Phone ListView object with list

I have a object which contains 5 list of object, and I would like to display this object in only one listview, I tried a lot of different things, like groups, but I can't find a solution. This is my object :

    public class SearchResult
{
    public List<User> artist { get; set; }
    public List<User> user { get; set; }
    public List<Music> music { get; set; }
    public List<Album> album { get; set; }
    public List<Pack> pack { get; set; }
}

How can I bind 5 list and display the information a need for each one by using a Template.

Thanks.

So you are looking for something like the Search results in the XBox Music app? It is probably just multiple ListViews, but if you really want all of them in a single ListView, you have to:

  • Put your lists together in a ListOfLists (List>), so you can use it with CollectionViewSource.
  • Or: Implement IGrouping on your SearchResult.

Then you can just use the GroupStyle on the Listview and ItemTemplateSelector will help you use different Templates on each Type.

So you will have to change your data structure if you want to bind it.

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