Posted 17 October 2017, 4:13 am EST
For example, I have these two classes…
Model: Person.cs , Hobby.cs
public class Persona : BindableBase
{
private string _Name;
public string Name
{
get { return _Name; }
set { SetProperty(ref _Name, value); }
}
private string _LastName;
public string LastName
{
get { return _LastName; }
set { SetProperty(ref _LastName, value); }
}
private ObservableCollection<Hobby> _ListHobbies;
public ObservableCollection<Hobby> ListHobbies
{
get { return _ListHobbies; }
set { SetProperty(ref _ListHobbies, value); }
}
}
public class Hobby : BindableBase
{
private string _Description;
public string Description
{
get { return _Description; }
set { SetProperty(ref _Description, value); }
}
}
ViewModel: PersonViewModel.cs
public class PersonViewModel : BindableBase
{
private ObservableCollection<Persona> _Person;
public ObservableCollection<Persona> Person
{
get { return _Person; }
set { SetProperty(ref _Person, value); }
}
public PersonViewModel()
{
this.Person = new ObservableCollection<Persona>()
{
new Persona()
{
Name ="Erick",
LastName ="Duarte",
ListHobbies= new ObservableCollection<Hobby>()
{
new Hobby{Description="Guitar"}
}
},
new Persona()
{
Name ="Andres",
LastName ="Lopez",
ListHobbies= new ObservableCollection<Hobby>()
{
new Hobby{Description="Guitar"},
new Hobby{Description="Play XBox"}
}
},
new Persona()
{
Name ="Ana",
LastName ="Perez",
ListHobbies= new ObservableCollection<Hobby>()
{
new Hobby{Description="Piano"},
new Hobby{Description="Gym"},
new Hobby{Description="Shopping"},
new Hobby{Description="Online games"}
}
}
};
}
}
XAML: Person.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="AuthExpress.Views.Person"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:c1="clr-namespace:C1.Xamarin.Forms.Grid;assembly=C1.Xamarin.Forms.Grid"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True">
<ContentPage.Content>
<c1:FlexGrid ItemsSource="{Binding Person}"
AutoGenerateColumns="False">
<c1:FlexGrid.Columns>
<c1:GridColumn Binding="Name" Header="Name" />
<c1:GridColumn Binding="LastName" Header="LastName" />
</c1:FlexGrid.Columns>
<c1:FlexGrid.Behaviors>
<c1:FlexGridDetailProvider Height="Auto" DetailVisibilityMode="ExpandMultiple">
<DataTemplate>
<c1:FlexGrid ItemsSource="{Binding ListHobbies}"
AutoGenerateColumns="False">
<c1:FlexGrid.Columns>
<c1:GridColumn Binding="Description" Header="Hobby" />
</c1:FlexGrid.Columns>
</c1:FlexGrid>
</DataTemplate>
</c1:FlexGridDetailProvider>
</c1:FlexGrid.Behaviors>
</c1:FlexGrid>
</ContentPage.Content>
</ContentPage>
iOS:
https://www.dropbox.com/s/m4v4o5hzdt12pdw/Simulator%20Screen%20Shot%20-%20iPhone%208%20-%202017-10-17%20at%2010.52.47.png?dl=0
Android (I would like it to look just like on iOS):
https://www.dropbox.com/s/38alcfhixahbc9r/AndroidCapture.png?dl=0
By the way, the Android version I use is 6.0 onwards and componentone is the most recent 189
Thanks a lot for your help Kelley!