【发布时间】:2013-01-26 19:24:21
【问题描述】:
我正在制作一个 WP7 应用程序并以 json 格式从我的 webapi 获取数据。我想知道如何进行数据绑定?我需要创建一个具体的类还是只使用 JArray?
[{"Id":"fe480d76-deac-47dd-af03-d5fd524f4086","Name":"SunFlower Seeds","Brand":"PC"}]
JArray jsonObj = JArray.Parse(response.Content);
this.listBox.ItemsSource = jsonObj;
<ListBox x:Name="listBox" FontSize="26" Margin="0,67,0,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" Width="100"/>
<TextBlock Text="{Binding Brand}" Width="100"/>
<TextBlock Text="{Binding Name}" Width="100"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
【问题讨论】:
标签: windows-phone-7 xaml data-binding json.net