Open doriangh opened 4 years ago
Hi @doriangh thanks for the report.
When you talk about "Grouped Accordion ListView" is that something custom you have created or a third-party control or something?
It would be great if you could provide a little reproduction project that shows the issue. Same goes for the other issue you just opened.
Hello! Here's a reproduction link. https://github.com/doriangh/AccordionListViewProblem As I can see the groups don't have the children data inside, but it doesn't matter as the group expands.
The reproduction link works for both issues as closing the group calls Clear() method.
Thank you!
So, I'm not really sure if this is a bug. While this is clearly possible with a ListView
, I don't think this was an intended use-case. I have however managed to come up with (some kind of) workaround.
Depending on how you want to reference your ListView
you can do something like this.
public ICommand ExpandGroup => new Command<TestItemGroupModel>(group =>
{
if (!group.Expanded && GroupItems.Any(x => x.Expanded))
GroupItems.FirstOrDefault(x => x.Expanded).Expanded = false;
group.Expanded = !group.Expanded;
// This was added
MessagingCenter.Send(this, "scrollit");
});
public ItemsPage()
{
InitializeComponent();
BindingContext = viewModel = new ItemsViewModel();
// This was added
MessagingCenter.Subscribe<ItemsViewModel>(this, "scrollit", m => ItemsListView.ScrollTo(m.GroupItems.FirstOrDefault(i => i.Expanded)?[0], ScrollToPosition.Start, false));
}
You can do it a bit differently and definitely add error handling, but this way the opened group will scroll into view.
You might have better luck with using the CollectionView
where you have more fine-grained control over scrolling and such, or maybe keep your eye on #9044
Thank you very much for your reply. I have tested the workaround and can confirm it is working. I have tried using a CollectionView, but I had no success in converting from ListView to CollectionView with my approach of an accordion ListView. Maybe if anyone can figure out a way, I'd be thankful. So far, with Xamarin.Forms 4.5 the app crashes on Clear() method. And with Forms 4.4 the header layout I am using does not render well, and the header trigger is not firing.
But thanks anyway!
So far, with Xamarin.Forms 4.5 the app crashes on Clear() method. And with Forms 4.4 the header layout I am using does not render well, and the header trigger is not firing.
@doriangh can you log a bug? It'll be quicker to get this all working and fixed in CollectionView then it will be with ListView
Description
When having a Grouped ListView with accordions, when there are enough groups so it can fill the whole screen and even more, when going straight to the bottom group, it does not come into view. It expands under the screen.
Steps to Reproduce
Expected Behavior
The list view slightly scrolls up as to place into view the content of the group
Actual Behavior
The group expands but the data is underneath, and the user has to scroll to be able to see the data
Basic Information