Can anyone tell me why this doesn't work. I am targetting Windows at the moment.. when I run it the cells appear on the page but there is no text in them. I get the same problem with CollectionView. I have searched online for days. i have tried lots of suggestion online including different dot net versions I think this should be easy, but its got me beat!
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="testing6.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<ListView x:Name="EEE"
Grid.Row="1"
SeparatorColor="Black"
SeparatorVisibility="Default"
ItemsSource="{Binding fruits}"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout
Margin="5,5"
Orientation="Vertical">
<Border Margin="0" Padding="8" StrokeThickness="5" Stroke="GreenYellow">
<Label Text="{Binding fruits}"/>
</Border>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
using System.Collections.ObjectModel;
namespace testing6
{
public partial class MainPage : ContentPage
{
public class Fruit
{
public string? FruitName { get; set; }
}
public ObservableCollection<Fruit> fruits = new ObservableCollection<Fruit>();
public ObservableCollection<Fruit> Fruits { get { return fruits; } }
public MainPage()
{
InitializeComponent();
fruits.Add(new Fruit() { FruitName = "Apple" });
fruits.Add(new Fruit() { FruitName = "Orange" });
fruits.Add(new Fruit() { FruitName = "Banana" });
fruits.Add(new Fruit() { FruitName = "Grape" });
fruits.Add(new Fruit() { FruitName = "Mango" });
EEE.ItemsSource = fruits;
}
}
}