如何将类中List类型的变量中的示例数据绑定到XAML(设计)页面
我一直在利用绑定示例数据,这样我就可以了解应用程序在运行时的样子 事情一直进展得很顺利,直到我不得不列出一个清单。我制作了一个示例应用程序来演示这个问题 Person.cs MainViewModelSampleData.xaml 我可以让设计视图正确显示字符串FullName、int Age和字符串Sex如何将类中List类型的变量中的示例数据绑定到XAML(设计)页面,xaml,windows-phone-8,data-binding,Xaml,Windows Phone 8,Data Binding,我一直在利用绑定示例数据,这样我就可以了解应用程序在运行时的样子 事情一直进展得很顺利,直到我不得不列出一个清单。我制作了一个示例应用程序来演示这个问题 Person.cs MainViewModelSampleData.xaml 我可以让设计视图正确显示字符串FullName、int Age和字符串Sex 我不知道也不明白的是如何绑定来自好友列表的数据,以便在设计视图中查看 解决方案是“提取”好友值 <vm:Person FullName="Bruce Wayne" Age="32" S
我不知道也不明白的是如何绑定来自好友列表的数据,以便在设计视图中查看 解决方案是“提取”好友值
<vm:Person FullName="Bruce Wayne" Age="32" Sex="Male">
<vm:Person.Friends>
<x:String>First</x:String>
<x:String>Second</x:String>
</vm:Person.Friends>
根据应用程序x的版本:字符串是必需的,或者直接使用文本
<vm:Person FullName="Bruce Wayne" Age="32" Sex="Male">
<vm:Person.Friends>
First
Second
</vm:Person.Friends>
最后一个选项是添加以下名称空间
xmlns:System="clr-namespace:System;assembly=mscorlib"
<phone:PhoneApplicationPage.DataContext>
<local:Person Name="ww">
<local:Person.Friends>
<System:String>one</System:String>
<System:String>one</System:String>
</local:Person.Friends>
</local:Person>
谢谢@Juan,我试过了,但似乎不起作用。我看到一条蓝色的曲线,上面写着,Windows Phone Silverlight项目不支持字符串。在这种情况下,请尝试其他选项直到不起作用。现在它说,列表'1的TypeConverter不支持从字符串转换。答案中的最后一个选项
<vm:Person FullName="Bruce Wayne" Age="32" Sex="Male">
<vm:Person.Friends>
First
Second
</vm:Person.Friends>
xmlns:System="clr-namespace:System;assembly=mscorlib"
<phone:PhoneApplicationPage.DataContext>
<local:Person Name="ww">
<local:Person.Friends>
<System:String>one</System:String>
<System:String>one</System:String>
</local:Person.Friends>
</local:Person>