我是一個Windows Phone 8新手,目前正在用數組綁定xaml掙扎。Windows Phone 8數據綁定到陣列
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"
}
它不工作,我越來越所有的文件丟失了,因爲我不從C#的背景來。那麼我如何才能做到這一點?
酷,會給這個,並嘗試並保持張貼。感謝您在此的時間,非常感謝:) –
感謝噸@Luke,得到它的工作:D –
@badZoke:優秀,很高興聽到它。 –