Updating carousel when collection changes

4 posts, 0 answers
  1. Rayne
    Rayne avatar
    241 posts
    Member since:
    Sep 2010

    Posted 16 May 2011 Link to this post

    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?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 May 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rayne
    Rayne avatar
    241 posts
    Member since:
    Sep 2010

    Posted 15 Jun 2011 Link to this post

    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);
    }
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Jun 2011 Link to this post

    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
Back to Top