【发布时间】:2017-07-11 19:09:00
【问题描述】:
我正在尝试在 Xamarin 中创建一个 listView,其中行中的某些元素会根据对象中的值而有所不同。 例如。备注型号:
public class Note
{
public string Title { get; set; }
public string Content { get; set; }
public bool Active { get; set; }
}
在 XAML 中:
<Label Text="{Binding Title}" TextColor="#f35e20" />
<Label Text="{Binding Content}" TextColor="#503026" />
<Button BackgroundColor="#000" />
我希望有按钮 BackgroundColor 取决于 Active 字段。如果Active 是false,则BackgroundColor 设置为红色。如果true 则BackgroundColor 设置为绿色。
我该怎么做?谢谢。
【问题讨论】: