Bug 40634 - CarouselView fires (or not) "ItemSelected" or "PositionSelected" in an buggie way (v2.2.0.18-pre3)
Summary: CarouselView fires (or not) "ItemSelected" or "PositionSelected" in an buggie...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris King
URL:
Depends on:
Blocks:
 
Reported: 2016-04-22 01:14 UTC by David CASBONNE
Modified: 2017-05-05 17:37 UTC (History)
3 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description David CASBONNE 2016-04-22 01:14:48 UTC
First, I would apologize for the "buggie way". I don't find the word which would explain what I want to say!

1. Event is not fired on the construction of the CarouselView.
When the CarouselView has its ItemsSource binded on a list with multiple elements, by default the first element is displayed but ItemSelected or PositionSelected is not fired.
I think it would be fired.

2. I'm not sure if it's the same bug or not but if it's not let me know and I would create another bug.

Example :
The Title of the ContentPage is based on the current displayed item of the CarouselView. To achieve that I've binded a property of my ViewModel to the ContentPage.Title and on the carouselView.ItemSelected I push the current selected item in a ViewModel property. Then, when this property is changed, PageTitle is changed and the ContentPage.Title is updated.

Behavior :
When starting sliding (to the left or to the right), ItemSelected (or PositionSelected) event is fired. But if I don't end my swipe (resulting in an unchanged view of the carouselview), PageTitle is already updated and is wrong.

Expected behavior :
ItemSelected and PositionSelected should be fired when the swipe is complete and the CarouselView has effectively changed its displayed item.
The actual behavior is more related to an ItemSelecting or PositionSelecting event I think.

If needed I could make a short video or a small demo project to help you.
Comment 1 Chris King 2016-04-22 17:12:03 UTC
David, thanks for your feedback. The first is 'by design'. Some folks seem to want it fired and others not. We've had a few requests for the behavior you describe so I'll raise the question again. 

As to the second point, I don't think we'll need a repro; we'll try find better platform hooks.
Comment 2 David CASBONNE 2016-04-23 01:58:29 UTC
Hi,

If it's "by design" it's OK. By binding the "Item" property of the carousel we could know the displayed item (if you could solve bug 40632) so it would be OK for me.

For the second part of the bug, I've changed a part of my code to use a binding on "Item" instead of event "ItemSelected".

Behavior is the same but it's different in iOS and Android (I haven't notice that yesterday).
- on iOS, as the swipe is started, ItemSelected and PositionSelected are fired and Item  is updated. It's this case that is buggie I think. With *ing events and Item update when swipe is complete it would be better in my opinion (and more close to design guidelines).

- on Android it's OK. When we start a swipe and not complete it. ItemSelected, PositionSelected are fired only when swipe is completed and Item is updated "normally".

Thanks you !
Comment 3 Chris King 2017-05-05 17:37:10 UTC
CarouselView to be deprecated and replaced with https://github.com/xamarin/Xamarin.Forms/pull/853