Xaml windows phone 8数据绑定到阵列

Xaml windows phone 8数据绑定到阵列,xaml,windows-phone-8,windows-phone,datacontext,Xaml,Windows Phone 8,Windows Phone,Datacontext,我是一名WindowsPhone8新手,目前正在努力与阵列进行xaml数据绑定 XAML: <phone:LongListSelector x:Name="LocationsData" Margin="0,0,-12,0" ItemsSource="{Binding}"> <phone:LongListSelector.ItemTemplate> <DataTemplate> <StackPanel Ma

我是一名WindowsPhone8新手,目前正在努力与阵列进行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>
位置的
\u数组\u
有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#出身,我对所有的文档都迷路了。那我怎么才能让它工作呢

这里的问题不在于数组,而是数据绑定的源(即
{binding name}
{binding approach}
中的
名称
{binding approach}
)必须是一个数组。数组中的对象没有名称为
name
neighborary
的属性,因此不会显示任何内容。事实上,您甚至可能在VisualStudio的输出窗口中看到绑定错误,提到它找不到
name
属性

我怀疑您的
LongListSelector
中有四个项目,但因为它们中没有任何文本,所以它们的大小为零,您看不到它们。尝试将带有一些静态文本(例如
)的
文本块添加到
堆栈面板
,查看是否出现四个
X
s


如果只需要将JSON显示为只读,那么应该可以将JSON反序列化为只读。然后将为每个JSON对象创建一个匿名类型,并为JSON对象中的每个属性创建一个(.NET)属性。例如,见。不过,如果运气好的话,我还没有测试过它。

酷,我会给你这个,并尝试与你保持联系。感谢您在这方面的时间,非常感谢:)
{
    "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"
}