I'm having trouble getting my model to show up when trying to databind it in XAML setting Xamarin's BindingContext...here's my simplified model code:
public class LeagueRootObject
{
public League League { get; set; }
public ObservableCollection<Match> Matches { get; set; }
public object Error { get; set; }
}
public class League
{
public int Id { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public DateTime PlayingDate { get; set; }
}
public class Match
{
public MatchDetail MatchDetail { get; set; }
public ObservableCollection<Player> Players { get; set; }
}
public class MatchDetail
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
public class Player
{
public PlayerDetail PlayerDetail { get; set; }
public object Rating { get; set; }
public int MatchPlayerId { get; set; }
}
public class PlayerDetail
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
and here's simplified XAML snippet:
<ListView ItemsSource="{Binding Path=Matches}" VerticalOptions="StartAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Path=MatchDetail.Name}"/>
<ListView ItemsSource="{Binding Path=Players}">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Path=PlayerDetail.FirstName}"/>
<!-- another ViewCell here seems to hide data somehow -->
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
which is placed in the root StackLayout
element of the Xamarin ContentPage
and whose BindingContext
is set to the LeagueRootObject
instance loaded properly from json (which I've checked in debugger as working).
The XAML code above is the best I've been able to do since adding Label
inside the StackLayout
contained in the inner ListView
's ViewCell
just doesn't show up properly...how can you add a ViewCell
(or any other type of cell for that matter) to the inner ListView
and build its View
so it can show all the data belonging to all of the inner collection objects (I'm currently only getting the first one to show up also which is a problem when there's more than one player)...what am I doing wrong, should a ListView
not be used that way and have some other 'View` control be used for outer objects, all I want is to show all inner objects grouped inside outer ones somehow please...
Thanks
GroupHeaderTemplate
but the innerItemTemplate
don't still show up, so the question stands...what is wrong with the XAML code above? – GI1