首页 > 解决方案 > 如何将 CSS 样式应用于 TextCell 并更改 TextColor

问题描述

我想用 CSS 样式更改ListViewTextCellTextColor 。

我尝试了以下方法,但颜色保持不变:

MenuPage TextCell {
    color: aqua;
    textcolor: aqua;
    text-color: aqua;
    TextColor: aqua;
}

标签: xamarin.formsxamarin.forms-styles

解决方案


我对 TextCell 没有运气。但是,如果您可以将其设为 ViewCell 中的标签:

<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell>
            <StackLayout>
                <Label Text="{Binding}" />
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>

然后您可以使用 CSS 对其进行样式设置:

ListView StackLayout Label {
    font-size: 14;
    color: black;
}

推荐阅读