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