【发布时间】:2011-11-22 21:10:30
【问题描述】:
我有这些来自 XML 的数据:
var searched = from c in xml.Descendants("tbody").Descendants("tr")
let team = c.Element("td").ElementsAfterSelf("td")
select new Time
{
a = c.Element("td").ElementsAfterSelf("td").First().Value,
b = Int32.Parse(c.Descendants("td").ElementAt(3).Value),
c = Int32.Parse(c.Descendants("td").ElementAt(4).Value),
d = Int32.Parse(c.Descendants("td").ElementAt(5).Value),
e = Int32.Parse(c.Descendants("td").ElementAt(6).Value),
f = Int32.Parse(c.Descendants("td").ElementAt(7).Value),
g = Int32.Parse(c.Descendants("td").ElementAt(8).Value),
h = Int32.Parse(c.Descendants("td").ElementAt(9).Value),
i = Int32.Parse(c.Descendants("td").ElementAt(10).Value),
j = float.Parse(c.Descendants("td").ElementAt(11).Value)
};
完成此操作,我将在ListBox 中显示它们:
foreach (var item in searched)
{
listBox1.Items.Add(item.a + " " + item.b + " " + item.c + " " +
item.d + " " + item.e + " " + item.f + " " + item.g + " " +
item.h + " " + item.i + " " + item.j);
listBox1.Items.Add(" ");
}
它打印得很好,这就是我想要的。 现在我需要格式化它。 现在,它是这样打印的:
a b c d e f g h j
但是,变量的内容大小不同。所以信息没有得到很好的组织。
所以我想要类似的东西:
a|b|c|d|e|f|g|h|j
a|b|c|d|e|f|g|h|j
其中|代表一列。我正在考虑在列表框中设置一个网格,但后来我迷失了如何去做。
【问题讨论】:
标签: c# xaml windows-phone-7 data-binding listbox