Windows Phone 8.1 ListBox Group display

Source: Internet
Author: User

First understand the list group of friends can first look, the following link!
Http://www.cnblogs.com/linzheng/archive/2014/09/28/3999217.html

The content of the link just introduced the basic prototype, I put in some of my personal changes to add,
Hope to be helpful to everyone! If you find that I do not have any shortcomings, please suggest, communicate with each other to better progress

. xaml code

  1. <!--group Thumbnail list background color--
  2. <Page.Resources>
  3. <prim:jumplistitembackgroundconverter x:key= "Backgroundconverter" enabled= "#FF0086D0" disabled= "{ThemeResource Contentdialogdimmingthemebrush} "/>
  4. <prim:jumplistitemforegroundconverter x:key= "Foregroundconverter"/>
  5. </Page.Resources>

  6. <Grid>
  7. <Grid.Resources>
  8. <!--Create a data source object, note that the Itemcontent property is the property of the list of true underlying data in the data source, and you must set the property's value data source to navigate to the actual bound data entity object-
  9. <collectionviewsource x:name= "Itemcollectsource" issourcegrouped= "true" itemspath= "Internallist"/>
  10. </Grid.Resources>
  11. <semanticzoom x:name= "SemanticZoom" >
  12. <SemanticZoom.ZoomedInView>
  13. <!--Place the GridView (or ListView) here to represent a magnified view--
  14. <listview x:name= "InView" >
  15. <ListView.GroupStyle>
  16. <groupstyle hidesifempty= "True" >
  17. <!--template for displaying data items for the header of a list--
  18. <groupstyle.headertemplate >
  19. <DataTemplate>
  20. <border background= "#FF0086D0" height= "width=" >

  21. <textblock text= "{Binding Key}" fontsize= "37.333" foreground= "white" horizontalalignment= "Center" verticalalignment= "Center"/>
  22. </Border>
  23. </DataTemplate>
  24. </GroupStyle.HeaderTemplate>
  25. </GroupStyle>
  26. </ListView.GroupStyle>
  27. <!--a template for displaying data items for a list--
  28. <ListView.ItemTemplate>
  29. <DataTemplate>
  30. <StackPanel>
  31. <textblock text= "{Binding Title}" height= "Fontsize=" ></TextBlock>
  32. </StackPanel>
  33. </DataTemplate>
  34. </ListView.ItemTemplate>
  35. </ListView>
  36. </SemanticZoom.ZoomedInView>
  37. <SemanticZoom.ZoomedOutView>
  38. <!--Place the GridView (or ListView) here to represent a smaller view--
  39. <gridview x:name= "Outview" background= "#7F000000" margin= "0,10,0,0" >
  40. <!--template for displaying data items for a pop-up grouped list view--
  41. <GridView.ItemTemplate>
  42. <DataTemplate>
  43. <grid width= "height=" >
  44. <border background= "{Binding converter={staticresource Backgroundconverter}}" margin= "0,10,10,0" >
  45. <textblock text= "{Binding group.key}" fontsize= "37.333" horizontalalignment= "left" verticalalignment= "Bottom"
  46. Foreground= "{Binding converter={staticresource Foregroundconverter}}"/>
  47. </Border>
  48. </Grid>
  49. </DataTemplate>
  50. </GridView.ItemTemplate>
  51. </GridView>
  52. </SemanticZoom.ZoomedOutView>
  53. </SemanticZoom>
  54. </Grid>
Copy Code

, CS Code


  1. public void Fun ()
  2. {
  3. This. InitializeComponent ();
  4. Create a normal data collection first
  5. list<item> Mainitem = new list<item> ();
  6. for (int i = 0; i <; i++)
  7. {
  8. Mainitem.add (new Item {Content = "a", Title = "Test A" + i});
  9. Mainitem.add (new Item {Content = "B", Title = "Test B" + i});
  10. Mainitem.add (new Item {Content = "c", Title = "Test C" + i});

  11. Mainitem.add (new Item {Content = "D", Title = "Test A" + i});
  12. Mainitem.add (new Item {Content = "F", Title = "Test B" + i});
  13. Mainitem.add (new Item {Content = "G", Title = "Test C" + i});

  14. Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
  15. Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
  16. Mainitem.add (new Item {Content = "c", Title = "Test C" + i});

  17. Mainitem.add (new Item {Content = "H", Title = "Test A" + i});
  18. Mainitem.add (new Item {Content = "I", Title = "Test B" + I});
  19. Mainitem.add (new Item {Content = "M", Title = "Test C" + i});

  20. Mainitem.add (new Item {Content = "N", Title = "Test A" + i});
  21. Mainitem.add (new Item {Content = "O", Title = "Test B" + i});
  22. Mainitem.add (new Item {Content = "P", Title = "Test C" + i});

  23. Mainitem.add (new Item {Content = "Q", Title = "Test A" + i});
  24. Mainitem.add (new Item {Content = "R", Title = "Test B" + i});
  25. Mainitem.add (new Item {Content = "S", Title = "Test C" + i});

  26. Mainitem.add (new Item {Content = "T", Title = "Test A" + i});
  27. Mainitem.add (new Item {Content = "W", Title = "Test B" + i});
  28. Mainitem.add (new Item {Content = "V", Title = "Test C" + i});

  29. Mainitem.add (new Item {Content = "U", Title = "Test A" + i});
  30. Mainitem.add (new Item {Content = "X", Title = "Test B" + i});
  31. Mainitem.add (new Item {Content = "Y", Title = "Test C" + i});
  32. Mainitem.add (new Item {Content = "Z", Title = "Test C" + i});
  33. }
  34. Using LINQ syntax to transform an ordinary data collection into a collection of data for an ingredient group
  35. List<itemingroup> Items = (from item on Mainitem group item by item. Content into NewItems select New Itemingroup {Key = Newitems.key, itemcontent = Newitems.tolist ()}). ToList ();

  36. list<alphakeygroup<item>> Items = Alphakeygroup<item>. Creategroups (
  37. Mainitem,
  38. (Item s) = = {return s.title;},
  39. true);

  40. Set the data source for the CollectionViewSource object
  41. This.itemcollectSource.Source = Items;
  42. To bind two views separately
  43. Outview.itemssource = itemcollectSource.View.CollectionGroups;
  44. Inview.itemssource = Itemcollectsource.view;
  45. }
  46. }
  47. The entity class of the grouped entity class, which is the outermost data item of the grouped data collection
  48. public class Itemingroup
  49. {
  50. Group header properties for grouping
  51. public string Key {get; set;}
  52. Grouped data collection
  53. Public list<item> itemcontent {get; set;}
  54. }
  55. List of data entity classes
  56. public class Item
  57. {
  58. public string Title {get; set;}
  59. public string Content {get; set;}
  60. }
Copy Code

Windows Phone 8.1 ListBox Group display

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.