This is a migrated thread and some comments may be shown as answers.

Updating carousel when collection changes

3 Answers 107 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 16 May 2011, 10:34 PM
I'm binding my carousel to a child collection of an item on my ViewModel. This collection is an EntityCollection, but when I add an item to that bound collection, it's not being reflected in the carousel. It's not picking up the change.

My bound collection is a child collection to a EF entity object on my viewModel. I've tried capturing the event on my viewmodel and Raising a PropertyChanged on it, but that doesn't work either. My code is being fired, but that isn't updating the carousel. Maybe because I'm raising a propertyChanged, not a collection Changed?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 May 2011, 09:23 AM
Hello Rayne,

I have tried to reproduce the issue you reported, but unfortunately I was not able to. May you take a look at the sample attached to verify whether there is any misunderstandings according to your requirements ?

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rayne
Top achievements
Rank 1
answered on 15 Jun 2011, 03:29 PM
In your sample, you are getting the ItemsSource as an IList of Player. Then adding to the list.

In my code, the binding the button click to a delegateCommand on my viewmodel, that adds a new items to the collection. My VM contains a property that is an EF entity (Complaint). This entity has a child collection (EntityCollection) Photos that I'm binding the carousel to.

If I put a breakpoint in my code after adding a new item to the bound collection, I can see that the Items Collection of the carousel has only has 4 items and the ItemsSource collection has 5 items. So it's not updating the carousel when I add a new item to the bound collection.

The selected item is also bound and I was hoping that would sync them up and show the newly added item, but no such luck. The only way I can get it to work is to do this:
PhotosCarousel.Rebind();
var items = PhotosCarousel.Items;
if (items.Count > 0)
{
  items.MoveCurrentToLast();
  PhotosCarousel.BringDataItemIntoView(items.CurrentItem);
}
0
Maya
Telerik team
answered on 20 Jun 2011, 10:45 AM
Hi Rayne,

You may try to wrap your images in an ObservableCollection. Thus RadCarousel will be aware of the changes. I am sending you a sample project using images illustrating how you may add a new image. Another possible solution may be to call Rebind() method of the RadCarousel after the item is added. 
As for setting the new image as the topmost one, you need to call BrindDataItemIntoView method (just as you did). Setting it as the selected once does not guarantee it will be at the front position.

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Carousel
Asked by
Rayne
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or