Carousel View sets selected index to 0 on init even though selected item is not index 0
See original GitHub issueI am in a situation where I am trying to load a page with the CarouselView
at the position that the user was in when they last left the page (or closed the application). I am doing this by binding the SelectedItem
to the last selected item in the carousel’s bound list. What is happening though is that the CarouselView
always starts at index 0 regardless of what the SelectedItem
is bound to and then will change the SelectedItem
to match the index.
When I put a break point in the property changed event, to observe what is happening, I am noticing that the carousel starts with the correct selected item but with an index of -1, since I am loading a list and the selected item gets bound before the list is done loading. I guess since the Item isnt found in the empty list it sets the index to -1. I am assuming that after the page is done initializing it sets that -1 to 0? and then that updates the SelectedItem
as a consequence. I have tried to set the binding of SelectedItem
after the ItemSource
property changed but this doesnt work either.
I might be wrong in that assessment but I guess my question is: is it possible to drive the carousel from a bound SelectedItem
? or do I have to bind to the SelectedIndex
to get the kind of behavior I am wanting?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (11 by maintainers)
hey @AndreiMisiukevich, sorry for the delayed response. I actually ended up just converting the selected item to and index and binding to the SelectedIndex instead of the SelectedItem and it works fine now. I haven’t had the time to go back and try it the way you suggested here. I must’ve missed that property on the carousel but it sounds like it would help this situation. Thank you for the swift response!
I’ll open a new ticket, thanks Andrei. So we bind ItemSource to generic List<T>, and Selected Index. Attaching the project ot debug is a good idea - I’ll try that, and report what I find.