Bug 40632 - CarouselView missed a "SelectedItem" property (v2.2.0.18-pre3)
Summary: CarouselView missed a "SelectedItem" property (v2.2.0.18-pre3)
Status: RESOLVED DUPLICATE of bug 40558
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-04-22 00:54 UTC by David CASBONNE
Modified: 2017-01-03 20:14 UTC (History)
4 users (show)

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

Demo bug 40632 (74.28 KB, application/zip)
2016-04-26 01:30 UTC, David CASBONNE

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:

Description David CASBONNE 2016-04-22 00:54:54 UTC
When working with a CarouselView it would be great to bind a "SelectedItem" to report the current item which is selected to the ViewModel.
"SelectedItem" should be a bindableproperty obviously.

When the CarouselView is constructed, SelectedItem would have the current item and not a null value.

If you need some other explanation fell free to ask !
Comment 1 Chris King 2016-04-22 17:20:12 UTC
Can you not bind to CarouselView.Item? Would you rather it be named SelectedItem?
Comment 2 David CASBONNE 2016-04-23 01:40:42 UTC
I apologize, I have read on Xamarin forums that Item property is not bindable so I haven't tried before posting this "bug".

So I have tried and it works partially. By partially I mean that if I swipe the carousel "Item" is updated so it's great.

But there are 2 remaining bugs :
- when constructed, "Item" is not set to the item displayed but it's null. I think "Item" should have the real displayed item.

- when setting "Item" in my viewmodel, carousel does not update its display. 

Concerning the name of the property, my preference goes to "SelectedItem" as it more clear than just "Item" but it's up to you.
Comment 3 Chris King 2016-04-25 04:32:06 UTC
I fixed the first of your two bugs. I may need a repro to see the second. Probably stick with Item just because that's what we started with.
Comment 4 FieldstrikeMobile 2016-04-25 07:49:02 UTC
Duplicate of https://bugzilla.xamarin.com/show_bug.cgi?id=40558?
Comment 5 David CASBONNE 2016-04-26 01:29:30 UTC
Hi Chris,

I attached a repro project when setting Item in ViewModel has no effect on the display.
A button in the View has a command and that command should update the "SelectedItem" property which has to update the carousel display. 
With a breakpoint on the "set" in "SelectedItem" property we could see that it's really updated but the carousel display but it doesn't seem to do anything...

I hope this project will help you.

For the naming, we could stay with "Item", it's not a real problem :)

@FieldStrikeMobile : yes it seems that these 2 bugs are closely related but Item is bindable in pre3. Have you tried ?
Comment 6 David CASBONNE 2016-04-26 01:30:49 UTC
Created attachment 15838 [details]
Demo bug 40632

Comment 7 FieldstrikeMobile 2016-04-26 07:50:02 UTC

are you sure Item is bindable in pre3? The property item is read only in pre 4
Comment 8 David CASBONNE 2016-04-27 01:51:46 UTC

You're right, my error...

In CarouselView, in pre3 I have :
public static readonly BindableProperty ItemProperty;

That explain why display is not updated when I set Item property in ViewModel.

So know it's the same bug as 40558 :)
Comment 9 Samantha Houts [MSFT] 2017-01-03 20:14:28 UTC

*** This bug has been marked as a duplicate of bug 40558 ***