Hello!
I've been trying to do this with Custom renderers but it seems to me that this may not be possible. Does anyone know some information about this?
I have tried with different approaches like:
https://stackoverflow.com/questions/1074006/is-it-possible-to-disable-floating-headers-in-uitableview-with-uitableviewstylep
https://stackoverflow.com/questions/664781/change-default-scrolling-behavior-of-uitableview-section-header/3984585#3984585
https://stackoverflow.com/questions/19056428/how-to-hide-first-section-header-in-uitableview-grouped-style
But without ant luck, any comment on this would be appreciate it.
I'm not aware of an exact solution for that, but a workaround might be to remove all grouping, an insert a new row whenever you would have displayed a grouped header and put more logic into your DataTemplate to display a different kind of cell depending If a header or cell is being displayed.
Can try it in a custom renderer as seen here https://forums.xamarin.com/discussion/34696/listview-grouped-style-on-ios
A much better and cleaner solution to this problem is to use an iOS platform-specific feature for Xamarin.Forms that allows you to easily set the ListView Group Header Style in XAML (or code behind) in one line as follows:
<ContentPage ... xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"> <StackLayout Margin="20"> <ListView ios:ListView.GroupHeaderStyle="Grouped"> ... </ListView> </StackLayout> </ContentPage>
Answers
Bump.
Any information about this would be much appreciate it.
I'm not aware of an exact solution for that, but a workaround might be to remove all grouping, an insert a new row whenever you would have displayed a grouped header and put more logic into your DataTemplate to display a different kind of cell depending If a header or cell is being displayed.
@seanyda I haven't thought of that approach thanks for the idea! nevertheless this will imply some refactor of my code that will affect my sprint.
Can try it in a custom renderer as seen here https://forums.xamarin.com/discussion/34696/listview-grouped-style-on-ios
@yawno Exactly! thanks for the answers the bad news is that I've lost the pull to refresh feature.
@15mgm15 Unfortunately my project doesn't include pull to refresh so I am not 100% sure what your problem is. The issue is probably occurring because the new table being created is missing something that the old table had. My best bet is that its the RefreshControl. You could try to change the code to this.
Let me know if that helps as I don't have a project where I can test it myself
Also to anyone else reading this forum I had problems where there was weird spacing for my section headers, and there was a problem with extra spacing at the top of the listview. The following fixed this.
@yawno too good to be true, I think I will grab the whole refresh control from the
ListViewRenderer
of the Xamarin.Forms GitHub and give it a try, Thanks for the ideas tho.I did also have the same spacing issues and solve it by using:
tbl.SeparatorStyle = UITableViewCellSeparatorStyle.None;
@15mgm15 Did you manage to get the refresh working on the custom renderer. If so how did you manage it?
@MarkL Yes, I had to set assign a native pull to refresh to my custom ListView. I am pretty sure you can get the previous object (properties and events) and assign them to the new list object.
@15mgm15 That's what I did but I ended up getting 2 refresh spinners appearing in the list view, one correctly placed from the native refresh control and another one that appeared on the right hand side when the forms listview IsRefreshing property got set to true. I've managed to hack around that now by overriding the properties on an inherited listview and using reflection to fire off its Refreshing event. Thanks for your input though
@MarkL Yeah! exactly the same thing happened to me and I also resolved it using hacks
A much better and cleaner solution to this problem is to use an iOS platform-specific feature for Xamarin.Forms that allows you to easily set the ListView Group Header Style in XAML (or code behind) in one line as follows:
@SandipAhluwalia I didn't notice this was ever released, you rock! I will do a blog post about this.