XAML背景颜色和文本颜色不变

时间:2017-09-18 15:12:27

标签: xaml xamarin xamarin.forms

我不知道我的代码是否显示FOOS的列表。它确实生成了一个可点击的列表项,该列表项转到正确的详细信息页面,问题是列表项是空白的还是所有文本是白色的。我无法弄清楚哪个。enter image description here

<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"}};

1 个答案:

答案 0 :(得分:3)

这里有一些错误(也许这只是一个糟糕的复制/粘贴工作):

  • ViewCell.View没有BackgroundColor属性,请改用<{1}}
  • StackLayout.BackgroundColor应为label(首都事项)

当我对您的代码进行更改时,它对我来说运行正常:

Label