xaml - 当 ItemSource 只是一个 List 时如何自定义 TextCell?
问题描述
我想在 Xamarin.Forms 中创建一个字符串的 ListView,但我没有在文档中找到如何做到这一点。
<ListView>
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>mono</x:String>
<x:String>monodroid</x:String>
<x:String>monotouch</x:String>
<x:String>monorail</x:String>
<x:String>monodevelop</x:String>
<x:String>monotone</x:String>
<x:String>monopoly</x:String>
<x:String>monomodal</x:String>
<x:String>mononucleosis</x:String>
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<TextCell>
<!--How to customize this textcell with the content of the array?-->
</TextCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我试过这个,但我只得到字典中不存在密钥的错误。当 ItemSource 只是字符串时,如何自定义 ListView-Cell?
解决方案
使用.
语法绑定当前对象
<TextCell Text="{Binding .}" />
推荐阅读
- python - Cannot call static content correctly
- arrays - 将矩阵中的每个元素乘以向量中的每个元素
- visual-studio - 抛出异常时执行不会停止
- html - 如何在引导程序 4 中的某些跨度周围获得紧密的边界?
- css - Gulp isn't compiling the scss code into css
- sql - Teradata 动态插入 - 循环?
- c++ - Defining methods outside of a class's scope via function pointers
- c# - Is there a DataGridView that supports VirtualMode and hierarchical data?
- ios - Swift 4 Firebase 云消息传递仅适用于单个设备
- javascript - 添加动态