我不知道我的代码是否显示FOOS
的列表。它确实生成了一个可点击的列表项,该列表项转到正确的详细信息页面,问题是列表项是空白的还是所有文本是白色的。我无法弄清楚哪个。
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MaopApplication.Views.PipelineSearch">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" >
<Entry Placeholder="Search With PipelineName" Text="{Binding SearchText}" ></Entry>
<Button Text="Search" Command="{Binding SearchPipes}" />
</StackLayout>
<ListView ItemsSource="{Binding Foos}" ItemTapped="OnListViewItemTapped" ItemSelected="OnListViewItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View BackgroundColor="Red">
<StackLayout>
<label Text="wtf" TextColor="Black"></label>
<label Text="{Binding Test}"TextColor="Black"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
创建FOOS的代码
var Foos = new List<object>() {new {Test = "foo"}, new {Test = "bar"}};
答案 0 :(得分:3)
这里有一些错误(也许这只是一个糟糕的复制/粘贴工作):
ViewCell.View
没有BackgroundColor
属性,请改用<{1}} StackLayout.BackgroundColor
应为label
(首都事项)当我对您的代码进行更改时,它对我来说运行正常:
Label