Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last child of CarouselLayout isn't full width if data source set asyncronously #7

Open
SmartyP opened this issue Nov 27, 2015 · 2 comments

Comments

@SmartyP
Copy link

SmartyP commented Nov 27, 2015

I noticed an issue where the carousel (using the dots setup) would work fine for the first 3 pages, but the 4th page was cutoff and not full width. I spent a few hours trying to figure out what was going on, and how my example was different from the sample. I finally realized that the difference was that I was setting up my bound collection of items after the view was created instead of having the collection already created when the UI was being laid out. I discovered that if I made sure the collection was already created when the view was created then the paging would work properly (last item would properly be full width).

In the end, I discovered that if I just edited the CarouselLayout.LayoutChildren() method to put the call to base.LayoutChildren() at the bottom of the method instead of the top, it would lay out fine even with the collection built at a later point. I don't totally understand why this works, but I wanted to point it out in case anyone else runs into the issue.

For a bit more detail - the LayoutChildren() method would fire 5 times for 4 items whether the collection existed up front, or was setup later. However, if the collection already existed the Children count would be 4 every time it fired, whereas if the collection was created later it would still fire 5 times, but the Children count be 0, 1, 2, 3, 4 with each subsequent call (which is odd since the ObservableCollection is set to the full list and not added to itself - but I digress). No idea if this factors in to the underlying issue or not.

Thanks so much for creating this control and sample!

@RedTahr
Copy link

RedTahr commented Dec 13, 2015

@SmartyP thanks for your solution to a problem I've had for a while. I hadn't got as far as to think of moving the call to base to the end of the function, had been distracted trying to work out where the half-width style number was coming from. I thought the problem may have been in my conversion of bits of this into XAML, turns out it was just one of those sequence bugs. Thanks again.

@chrisriesgo
Copy link
Owner

@SmartyP - Glad the example has been helpful! I'll review my sample and make sure that it reflects your findings. Thanks for posting the extra help here 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants