我已将文本分配给标签控件,并且尝试读取控件的文本值,如下所示,
private DataTemplate GetDataTemplate()
{
var dataTemplate = new DataTemplate(() =>
{
var rowGrid = new Grid
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
ColumnSpacing = 15,
Margin = new Thickness(5),
BackgroundColor = Constants.BackgroundColor
};
// Some code
var isPaymentPlanEnding = new Label { };
isPaymentPlanEnding.SetBinding(Label.TextProperty, "IsPaymentPlanEnding");
if (isPaymentPlanEnding.Text.ToLower() == "true")
{
var highlightBoxView = new BoxView
{
BackgroundColor = Constants.MMSGErrorRed
};
highlightGrid.Children.Add(highlightBoxView);
highlightGrid.Children.Add(rowGrid);
return new ViewCell { View = highlightGrid };
}
else
{
return new ViewCell { View = rowGrid };
}
});
return dataTemplate;
}
请让我知道,如何从标签控件中读取值。