0
我想要做的是,我创建了一个ViewCell并将其绑定到ListView。在ViewCell中,我有标题标签,我想根据数据库中的数据进行更改。 这将是什么最佳做法?如何使用Xamarin Forms中的绑定数据更改视单元的外观?
这里我的代码块
型号 -
public class helplineservices
{
public string title { get; set; }
public bool isenable { get; set; }
}
ViewCell -
public class HelpLineCell : ViewCell
{
#region binding view cell logic
public HelpLineCell()
{
BlackLabel title = new BlackLabel
{
FontFamily = Device.OnPlatform(
"Roboto-Black",
null,
null),
FontSize = Device.OnPlatform(
(ScreenSize.getscreenHeight()/47),
(ScreenSize.getscreenHeight()/47),
14
),
HorizontalTextAlignment = TextAlignment.Center,
TextColor = Color.FromHex("#FFFFFF"),
WidthRequest = ScreenSize.getscreenWidth()
};
title.SetBinding(Label.TextProperty, "title");
this.View = title;
}
#endregion
}
的ListView -
var HelpList = new ListView
{
IsPullToRefreshEnabled = true,
HasUnevenRows = true,
BackgroundColor = Color.Transparent,
RefreshCommand = RefreshCommand,
//row_list is a list that comes from database
ItemsSource = row_list,
ItemTemplate = new DataTemplate(typeof(HelpLineCell)),
SeparatorVisibility = SeparatorVisibility.None
};
我想通过检查一个布尔值更改标题颜色isenable的价值它来自数据库。 请帮帮我。
我尝试过,但我没有从ViewCell类数据库,能够在的IValueConverter使用越来越布尔值。 – Atul
哪个是您的模特? –
增加了模型。我想检查isenable属性并更改标题的文本颜色。我没有得到如何我可以使用isenable财产在条件检查 – Atul