【发布时间】:2014-03-05 00:09:02
【问题描述】:
我有以下课程:
public class agentes
{
[PrimaryKey]
public string id { get; set; }
public string idContinente { get; set; }
public string idCountry { get; set; }
public string title { get; set; }
public string desc { get; set; }
}
和
public class country
{
[PrimaryKey]
public string id { get; set; }
public string idContinent { get; set; }
public string title { get; set; }
}
我还有 2 个其他类,并且有一个列表,其中包含每种类型、国家和代理的对象。
我的列表中填充了从数据库查询到 sqlite 数据库的结果,如下所示:
public List<agentes> GetAllAgents()
{
List<agentes> AllAgents = new List<agentes>();
using (var db = new SQLite.SQLiteConnection(app.DBPath))
{
var query = db.Table<agentes>().OrderBy(c => c.idCountry);
foreach (var _Agent in query)
{
var Agente = new agentes()
{
desc = _Agent.desc,
id = _Agent.id,
idContinente = _Agent.idContinente,
idCountry = _Agent.idCountry,
title = _Agent.title,
};
AllAgents.Add(Agente);
}
}
return AllAgents;
}
现在,我打算做的是按国家/地区组织的代理商列表,因此看起来像
我从这样的东西开始,但显然它需要什么
<ScrollViewer Margin="30,30,0,30" Height="444">
<ItemsControl Name="ListCountries">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding title}" Foreground="Red" />
<ItemsControl Name="AgentsByCountry" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding desc}" Foreground="Black" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
有人有什么建议吗?
【问题讨论】:
-
您遇到了哪一点问题?分组?
-
是的,我不知道如何显示代理,以某种方式将它们与国家/地区分组,我可以在一个列表中显示所有代理,但这并不是我想要的最终结果就像我添加的图像一样
标签: c# xaml data-binding windows-8 windows-store