windows phone 8.1 listbox 分组显示
标签:des style blog http io ar 使用 for sp
初次了解list分组的朋友可以先看看,如下链接!
http://www.cnblogs.com/linzheng/archive/2014/09/28/3999217.html
链接的内容 只是介绍了基本雏形,我下面把我个人的一些修改加了进去,
希望能对大家有所帮助! 如果发现我哪有不足,请提出,相互交流才可以更好的进步
.xaml 代码
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Foreground="{Binding Converter={StaticResource ForegroundConverter}}"/>
-
-
-
-
-
-
-
-
复制代码
,cs 代码
- public void fun()
- {
- this.InitializeComponent();
- // 先创建一个普通的数据集合
- List
- mainItem = new List
- ();
- for (int i = 0; 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 });
- }
- // 使用LINQ语法把普通的数据集合转换成分组的数据集合
- //List Items = (from item in
mainItem group item by item.Content into newItems select new ItemInGroup
{ Key = newItems.Key, ItemContent = newItems.ToList() }).ToList();
- List> Items = AlphaKeyGroup
- .CreateGroups(
- mainItem,
- (Item s) => { return s.Title; },
- true);
- // 设置CollectionViewSource对象的数据源
- this.itemcollectSource.Source = Items;
- // 分别对两个视图进行绑定
- outView.ItemsSource = itemcollectSource.View.CollectionGroups;
- inView.ItemsSource = itemcollectSource.View;
- }
- }
- // 分组的实体类,也就是分组的数据集合最外面的数据项的实体类
- public class ItemInGroup
- {
- // 分组的组头属性
- public string Key { get; set; }
- // 分组的数据集合
- public List
- ItemContent { get; set; }
- }
- // 列表的数据实体类
- public class Item
- {
- public string Title { get; set; }
- public string Content { get; set; }
- }
复制代码
windows phone 8.1 listbox 分组显示
标签:des style blog http io ar 使用 for sp
原文地址:http://www.cnblogs.com/xiaoheibupahei/p/4076697.html
评论