0
ListView listView = new ListView();
listView.ItemTemplate = new DataTemplate(typeof(CustomVeggieCell));
listView.ItemsSource = sample;
Content = new StackLayout
{
Children ={
listView,
}
};
public class CustomVeggieCell : ViewCell
{
public CustomVeggieCell()
{
var image = new Image();
var typeLabel = new Label { };
typeLabel.SetBinding(Label.TextProperty, new Binding("contact"));
var string = typeLabel.Text;
if (typeLabel.Text == "Send")
{
image.Source = "Send.png";
}
else
{
image.Source = "draft.png";
}
var horizontalLayout = new StackLayout();
horizontalLayout.Children.Add(image);
View = horizontalLayout;
}
}
我已經使用Xamarin表單中的Json Web服務響應創建了一個listview。我需要根據值顯示圖像。 綁定值無法存儲在字符串中。它總是返回null。我想存儲綁定標籤文本。何實現這一目標?如何將綁定上下文標籤值保存爲xamarin表單中的字符串
謝謝..它的工作對我來說:) – Jeni