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;
}
}
I have created a listview with Json Web service response in Xamarin forms. I need to display an image depending on the value. Binding value couldn’t store in a string. It always returns null. I want to store the binding label text. Ho to achieve this?