[英]Where to set BackgroundColor of Monotouch.Dialog Element?
我正在扩展StyledMultilineElement类,以使RadioElement和StyledMultilineElement组合。 两者的选择和组合都工作正常,但是我的GetCell覆盖似乎无法正确设置单元格的背景色。
public override UITableViewCell GetCell (UITableView tv)
{
var cell = base.GetCell (tv);
bool selected = RadioIdx == this.rgroup.Selected;
cell.Accessory = selected ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
cell.BackgroundColor = selected ? UIColor.Cyan : UIColor.White;
return cell;
}
选中标记确实出现在所选元素上,告诉我所选布尔确实是正确的,但是背景颜色始终显示为白色。
我假设这只是因为我试图在GetCell方法中执行此操作,但是我不确定将其放置在其他位置。
所以问题是,由于显然它在这里不起作用,我应该在哪里设置BackgroundColor?
您是否尝试过设置实际Element本身的BackgroundColor属性?
有一些属性:
UITableViewCellAccessory Accessory
int Lines
UILineBreakMode LineBreakMode
UIColor TextColor
UIFont SubtitleFont
UIFont Font
这些似乎是设置样式的区域。
同样,如果选定的值发生更改,则该单元格实际上不会立即更新。 您还可以做的刷新单元格的操作是在要刷新单元格时调用此方法:
RootElement root = GetImmediateRootElement ();
root.Reload (this, UITableViewRowAnimation.Fade);
GetImmediateRootElement()
方法位于实际元素上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.