我试图把配对名称和图像装入湖塔里。 数据来自一个产出JSON的复印件。 我没有问题淡化数据,利用每个通道向我的班子补充数据。 这里的安排:
// Deserialize home page data
public void jsonHome_GetDataCompleted(object snder, DownloadStringCompletedEventArgs e)
{
NewReleasesCharts homeData = JsonConvert.DeserializeObject<NewReleasesCharts>(e.Result);
foreach (FeaturedReleases release in homeData.results.featuredReleases)
{
int releaseID = release.id;
string releaseName = release.name;
string releaseImg = release.images.large.url;
new ReleaseLarge()
{
url = releaseImg
};
new FeaturedReleases()
{
id = releaseID,
name = releaseName
};
}
this.listRelease.ItemsSource = homeData.results.featuredReleases;
}
我的课堂
public class NewReleasesCharts
{
//public Metadata metadata { get; set; }
public ResultHome results = new ResultHome();
public IEnumerator<ResultHome> GetEnumerator()
{
return this.results.GetEnumerator();
}
}
public class ResultHome
{
public List<FeaturedReleases> featuredReleases { get; set; }
//public List<FeaturedCharts> featuredCharts { get; set; }
//public List<TopDownloads> topdownloads { get; set; }
//public List<MostPopularReleases> mostPopularReleases { get; set; }
//public List<Components> components { get; set; }
internal IEnumerator<ResultHome> GetEnumerator()
{
throw new NotImplementedException();
}
}
public class FeaturedReleases
{
public int id { get; set; }
public string type { get; set; }
public string name { get; set; }
public string slug { get; set; }
public ReleaseImage images { get; set; }
}
public class ReleaseImage
{
//public ReleaseSmall small { get; set; }
public ReleaseMedium medium { get; set; }
public ReleaseLarge large { get; set; }
}
public class ReleaseLarge
{
public int width { get; set; }
public int height { get; set; }
public string url { get; set; }
public string secureUrl { get; set; }
}
页: 1
<ListBox Grid.Row="0" x:Name="listRelease">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<toolkit:HubTile Title="{Binding name}" Source="{Binding url}" Margin="10" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
现在只有<代码> 姓名/代码”在湖 T上显示。 我认为,这是因为名称和形象是不同阶层的,但我没有找到解决办法。 得到帮助。