【发布时间】:2014-05-02 17:55:05
【问题描述】:
这是我的模态,
public class main
{
public List<categories> categorieslist { get; set; }
}
public class categories
{
public int categoryId { get; set; }
public string categoryName { get; set; }
public List<pdf> pdfdocs { get; set; }
public List<video> videoFiles { get; set; }
}
public class pdf
{
public string URL { get; set; }
public string language { get; set; }
public string createdDate { get; set; }
public bool isFavorite { get; set; }
public bool isRead { get; set; }
}
我使用 JSON.NET 反序列化
main mainobj = JsonConvert.DeserializeObject<main>(App.hello);
我需要显示所选类别的 PDF 列表, 我使用 LINQ 过滤该特定类别,我无法绑定 PDF 列表..
pdf.ItemsSource = App.mainobj.categorieslist.Where(i => i.categoryId.Equals(s));
<ListBox x:Name="pdf" Margin="0,0,0,363" ItemsSource="{Binding}" Foreground="White">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding pdf.URL}" Foreground="White"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
【问题讨论】:
-
类别列表中有对象吗?
-
mainobj 是我创建的唯一对象,它是主类的一个实例
-
什么是 mainobj.categorieslist?里面有东西吗?
-
是的,里面有项目..类别列表,每个项目都有 categoryId、类别名称、pdf 列表和视频列表
-
你想绑定什么到列表框?
标签: c# xaml windows-phone-7 data-binding windows-phone-8