You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
@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.
@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 👍
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!
The text was updated successfully, but these errors were encountered: