我是 Windows phone 8 新手,目前正在努力使用数组进行 xaml 数据绑定。
XAML:
<phone:LongListSelector x:Name="LocationsData" Margin="0,0,-12,0" ItemsSource="{Binding}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding name}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding vicinity}" TextWrapping="NoWrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
。CS
LocationsData.DataContext = _array_of_locations;
有_array_of_locations
4个项目,
它们中的每一个都是有效的 JSON,
{
"geometry": {
"location": {
"lat": 12.923101,
"lng": 77.586057
}
},
"icon": "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id": "9a769bc2faaa79fe0ffbd85c2c28446940153331",
"name": "Domino's Pizza",
"opening_hours": {
"open_now": false
},
"price_level": 1,
"rating": 2.9,
"reference": "CnRsAAAAsI0LvfwZ_RC8PEDsJS3TfKkRkTn7d_2_-vw8tu_SYBYCJk2CmKt6RyRJtO5mG0Weq-R0jSsmyQOWHjU45itlrH1cN89EqgIA9Vtmvcih1xi6ZwpNewqZ8mNCQWWLDJvcT3AQLHGnFcn4E9a30Gvs9xIQeKGVsrSOKLDx4vYCjixIKhoUOGeosCJIVFDmE3-3qIPcIM7PSCs",
"types": [
"restaurant",
"food",
"establishment"
],
"vicinity": "11th Main Road, Jayanagar, Bangalore"
}
它不起作用,因为我不是来自 ac# 背景,所以我迷失了所有文档。那么我如何让这个工作呢?