Hi,
I am using a grouped ListView and want to show information of the group header displayed in the item.
Here is my xaml code:
<ListView ItemsSource="{Binding ParentList}" IsGroupingEnabled="true">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding ParentTitle}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding ParentTitle}"/> <!-- Here I want to get the GroupHeader Context -->
<Label Text="{Binding ChildTitle}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Here is my Parent class:
public class Parent : ObservableCollection<Child>
{
public ObservableCollection<Child> ChildList => this;
public String ParentTitle { get; set; }
}
Here is my Child class:
public class Child
public String ChildTitle { get; set; }
}
I already tried setting a x:Name on the GroupHeader but it is not unique so the item can not find it.
Can anyone please help?