Hello,
I have a Problem with the ListView. I have a custom Group Header Template and the Template is not always showing.
There are 2 ways where the Issue appears.
The first way is at the start of the app. When I start the app, I don't see the Group Header template.
The second way is after a pop from another side. When I select an item from the ListView and push to another page and then pop back, the Template doesn't appear.
Can you confirm the issues?
Code Xaml:
<listview:SfListView.GroupHeaderTemplate>
<DataTemplate>
<Grid ColumnDefinitions="*,Auto,*" Padding="0,10,0,0">
<border:SfBorder Grid.Column="1" BorderColor="Teal" BorderWidth="3" CornerRadius="30" BackgroundColor="Teal" >
<Label Text= "{Binding Key}" FontSize="22" FontAttributes="Bold" TextColor="Black" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Padding="50,0,50,0"/>
</border:SfBorder>
</Grid>
</DataTemplate>
</listview:SfListView.GroupHeaderTemplate>
Code .cs:
SfListView ListView;
protected override void OnAttachedTo(SfListView listView)
{
ListView = listView;
listView.DataSource.GroupDescriptors.Add(new GroupDescriptor()
{
PropertyName = "Date",
KeySelector = (object obj1) =>
{
var item = (obj1 as TourData);
return item.Date.Year;
},
});
this.ListView.DataSource.SortDescriptors.Add(new SortDescriptor()
{
PropertyName = "Date",
Direction = ListSortDirection.Descending
});
base.OnAttachedTo(listView);
}
Best regards
Lars
Hi Lars,
We have checked our simple sample based on the given code snippets. Unfortunately, we are unable to replicate the reported scenario on our end. We have attached the tested sample for your reference.
Please check our sample and let us know if you are still facing the same issue or not. If not, please modify our sample and revert us back with the following details,
Regards,
Lakshmi Natarajan
Hi Lakshmi,
I found the problem in my code. I've set the BindingContext wrong.
Many thanks for your help!
Best regards
Lars
Hi Lars,
If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you.
Lakshmi Natarajan