我有一个ListView
如下设置:
<ListView HasUnevenRows="true" BackgroundColor="Gray">
<ListView.Header>
<StackLayout Padding="20,35,20,10" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Label FontSize="13" TextColor="Gray" Text="Header text here"/>
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<ListView.DataTemplate>
<TextCell Text="{Binding CategoryName}" Detail="{Binding Count}">
</ListView.DataTemplate>
</ListView.ItemTemplate>
</ListView>
我有一个适用于 iOS 的渲染器并设置以下内容:
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var cell = base.GetCell(item, reusableCell, tv);
cell.BackgroundColor = UIColor.Red;
return cell;
}
不知何故,我整个人ListView
都在使用Gray
我为列表视图设置的背景。我想要发生的是具有Gray
颜色背景的ListView
(这意味着标题部分将具有灰色背景)并且具有Red
颜色背景的TextCell
. 我是否设置了错误的属性以获得所需的背景TextCell
?
您的自定义渲染器实际上并未返回单元格,因此您对 所做的更改BackgroundColor
不会通过。
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var cell = base.GetCell(item, reusableCell, tv);
cell.ContentView.BackgroundColor = UIColor.Red;
return cell;
}
更新:您应该cell.ContentView.BackgroundColor
改为设置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句