Can someone suggest how I can create a list of objects that contains a list of object?
In xaml
LoadList.ItemsSource = ViewModel.Loads;
LoadList.ItemTemplate = new DataTemplate(typeof(SelectLoadCell));
LoadList.HasUnevenRows = true;
Inside the ViewModel.Loads
<StackLayout BackgroundColor="#cae5ee" Orientation="Horizontal">
<StackLayout Orientation="Vertical">
<Label x:Name="Year" Font="Small" Text="{Binding Description}"></Label>
<ListView x:Name="SampleList" HasUnevenRows="true" BackgroundColor="#cae5ee" ItemsSource="{Binding MyList}" />
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Label x:Name="Info" Font="Small" TextColor="Green" Text="{Binding Place}"></Label>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</StackLayout>
</StackLayout>
Load.cs
public class Stop {
public string Location { get; set; }
public string Place { get; set; }
}
public Load ()
{
StopList.Add (new Stop { Location = "01", Place = "Bent" });
StopList.Add (new Stop { Location = "02", Place = "fewfe" });
StopList.Add (new Stop { Location = "02", Place = "12341212" });
}
public List<Stop> MyList {
get {
return StopList;
}
}