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
- <!--group Thumbnail list background color--
- <Page.Resources>
- <prim:jumplistitembackgroundconverter x:key= "Backgroundconverter" enabled= "#FF0086D0" disabled= "{ThemeResource Contentdialogdimmingthemebrush} "/>
- <prim:jumplistitemforegroundconverter x:key= "Foregroundconverter"/>
- </Page.Resources>
- <Grid>
- <Grid.Resources>
- <!--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-
- <collectionviewsource x:name= "Itemcollectsource" issourcegrouped= "true" itemspath= "Internallist"/>
- </Grid.Resources>
- <semanticzoom x:name= "SemanticZoom" >
- <SemanticZoom.ZoomedInView>
- <!--Place the GridView (or ListView) here to represent a magnified view--
- <listview x:name= "InView" >
- <ListView.GroupStyle>
- <groupstyle hidesifempty= "True" >
- <!--template for displaying data items for the header of a list--
- <groupstyle.headertemplate >
- <DataTemplate>
- <border background= "#FF0086D0" height= "width=" >
- <textblock text= "{Binding Key}" fontsize= "37.333" foreground= "white" horizontalalignment= "Center" verticalalignment= "Center"/>
- </Border>
- </DataTemplate>
- </GroupStyle.HeaderTemplate>
- </GroupStyle>
- </ListView.GroupStyle>
- <!--a template for displaying data items for a list--
- <ListView.ItemTemplate>
- <DataTemplate>
- <StackPanel>
- <textblock text= "{Binding Title}" height= "Fontsize=" ></TextBlock>
- </StackPanel>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
- </SemanticZoom.ZoomedInView>
- <SemanticZoom.ZoomedOutView>
- <!--Place the GridView (or ListView) here to represent a smaller view--
- <gridview x:name= "Outview" background= "#7F000000" margin= "0,10,0,0" >
- <!--template for displaying data items for a pop-up grouped list view--
- <GridView.ItemTemplate>
- <DataTemplate>
- <grid width= "height=" >
- <border background= "{Binding converter={staticresource Backgroundconverter}}" margin= "0,10,10,0" >
- <textblock text= "{Binding group.key}" fontsize= "37.333" horizontalalignment= "left" verticalalignment= "Bottom"
- Foreground= "{Binding converter={staticresource Foregroundconverter}}"/>
- </Border>
- </Grid>
- </DataTemplate>
- </GridView.ItemTemplate>
- </GridView>
- </SemanticZoom.ZoomedOutView>
- </SemanticZoom>
- </Grid>
Copy Code
, CS Code
- public void Fun ()
- {
- This. InitializeComponent ();
- Create a normal data collection first
- list<item> Mainitem = new list<item> ();
- for (int i = 0; i <; i++)
- {
- Mainitem.add (new Item {Content = "a", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "B", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "D", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "F", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "G", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "c", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "H", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "I", Title = "Test B" + I});
- Mainitem.add (new Item {Content = "M", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "N", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "O", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "P", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "Q", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "R", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "S", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "T", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "W", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "V", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "U", Title = "Test A" + i});
- Mainitem.add (new Item {Content = "X", Title = "Test B" + i});
- Mainitem.add (new Item {Content = "Y", Title = "Test C" + i});
- Mainitem.add (new Item {Content = "Z", Title = "Test C" + i});
- }
- Using LINQ syntax to transform an ordinary data collection into a collection of data for an ingredient group
- List<itemingroup> Items = (from item on Mainitem group item by item. Content into NewItems select New Itemingroup {Key = Newitems.key, itemcontent = Newitems.tolist ()}). ToList ();
- list<alphakeygroup<item>> Items = Alphakeygroup<item>. Creategroups (
- Mainitem,
- (Item s) = = {return s.title;},
- true);
- Set the data source for the CollectionViewSource object
- This.itemcollectSource.Source = Items;
- To bind two views separately
- Outview.itemssource = itemcollectSource.View.CollectionGroups;
- Inview.itemssource = Itemcollectsource.view;
- }
- }
- The entity class of the grouped entity class, which is the outermost data item of the grouped data collection
- public class Itemingroup
- {
- Group header properties for grouping
- public string Key {get; set;}
- Grouped data collection
- Public list<item> itemcontent {get; set;}
- }
- List of data entity classes
- public class Item
- {
- public string Title {get; set;}
- public string Content {get; set;}
- }
Copy Code
Windows Phone 8.1 ListBox Group display