[英]TextBox searchable Longlist selector shows Outofmemory exception in Windows Phone8?
[英]Longlist selector windows phone
我在Windows Phone 8的Xaml中有一个Longliseselector
我正在使用数据库填充它
它没有分组就可以正常工作,但是当我分组时,它只显示了几个空列表
此代码有效
using (Database ctx = new Database(Database.ConnectionString))
{
ctx.CreateIfNotExists();
var tdr = from p in ctx.Transactions
join c in ctx.Type on p.Type equals c.Id
where p.Date > DateTime.Today.AddDays(-1 * ra) && c.Type1.Equals(ty)
select new { Id = p.Id, amont = p.Amont, type = c.Name, des = p.Des, dated = p.Date };
list21.ItemsSource = tdr.ToList();
}
但是当我对它进行分组时,如果我有跳转列表,它就无法正常工作而不会出现任何错误
using (Database ctx = new Database(Database.ConnectionString))
{
ctx.CreateIfNotExists();
var tdr = from ii in
(
from p in ctx.Transactions
join c in ctx.Type on p.Type equals c.Id
where p.Date > DateTime.Today.AddDays(-1 * ra) && c.Type1.Equals(ty)
select new { Id = p.Id, amont = p.Amont, type = c.Name, des = p.Des, dated = p.Date }
)
group ii by ii.Id;
list32.ItemsSource = tdr.ToList();
}
我究竟做错了什么?
http://msdn.microsoft.com/en-us/library/windows/apps/jj244365(v=vs.105).aspx
您错过了KeyedList ...尝试:
{
ctx.CreateIfNotExists();
var tdr = from ii in
(
from p in ctx.Transactions
join c in ctx.Type on p.Type equals c.Id
where p.Date > DateTime.Today.AddDays(-1 * ra) && c.Type1.Equals(ty)
select new { Id = p.Id, amont = p.Amont, type = c.Name, des = p.Des, dated = p.Date }
)
group ii by ii.Id into iii select new KeyedList<string, COLLECTIONITEM>(iii);
list32.ItemsSource = new List<KeyedList<string, COLLECTIONITEM>>(tdr);
}
public class KeyedList<TKey, TItem> : List<TItem>
{
public TKey Key { protected set; get; }
public KeyedList(TKey key, IEnumerable<TItem> items)
: base(items)
{
Key = key;
}
public KeyedList(IGrouping<TKey, TItem> grouping)
: base(grouping)
{
Key = grouping.Key;
}
}
不要在GroupHeaderTemplate中忘记这一点:
<TextBlock Text="{Binding Key}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.