Change looping list item image at runtime

6 posts, 1 answers
  1. Gian Paolo Santopaolo
    Gian Paolo Santopaolo avatar
    13 posts
    Member since:
    Mar 2010

    Posted 07 Mar 2013 Link to this post

    Dear Telerik
        I'm using your fabolous looping list for WP8.
    Let's take your Orientation sample in LoopingList folder ( Examples_WP). What I'm trying to reach is to change the image of the selected item at rutime:
    eg. something happens to the collection I "bind" to your LoopingListDataSource then I want to change the image of the selected item.
    Can you help me with a sipped of code?

    regards
    -g
  2. Gian Paolo Santopaolo
    Gian Paolo Santopaolo avatar
    13 posts
    Member since:
    Mar 2010

    Posted 08 Mar 2013 Link to this post

    Dear Telerik Team
         any update about that?

    regards
    -g
  3. DevCraft banner
  4. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 11 Mar 2013 Link to this post

    Hello Gian Paolo,

    Just handle the SelectedIndexChanged event, take the selected data item and change the URI of the image it provides. If you correctly implement the INotifyPropertyChanged event the change should be reflected in the control.

    Kind regards,
    Deyan
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  5. Gian Paolo Santopaolo
    Gian Paolo Santopaolo avatar
    13 posts
    Member since:
    Mar 2010

    Posted 12 Mar 2013 Link to this post

    Hi Deyan
        unfortunately the selectedindexchanged doesn't fire but the list moves itself.
    Here is a sample project reproducing the issue http://sdrv.ms/Y6EeKt.
    Keep in mind that this is an extraction of a real word project where the data are stored in the cloud so all is asynchronous and when I save something the looping items have to be reloaded .

    thanks in advice!
        
  6. Answer
    Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 14 Mar 2013 Link to this post

    Hi Gian Paolo,

    I have taken a look at your code and I think for the purposes you have right now you're taking a rather complex path :).

    I am assuming you want to update the image of the selected item. Since you've already a special PictureLoopingItem which has a Picture URI property which fires the PropertyChanged event when updated, you need to handle the SelectedIndexChanged event (which btw works on my side) and update the URI property of the currently selected item with the URI of the new picture.

    You do not need to manually subscribe for PropertyChanged events on your ViewModel etc, this is done automatically by the Silverlight framework.

    The logic that you have put in the ItemUpdated event:

    if (count == ((MainViewModel)DataContext).Persons.Count && firstRun == true)
               {
                   this.loopingList.SelectedIndexChanged += LoopingListSelectedIndexChanged;
                   this.loopingList.SelectedIndex = 0;
                   firstRun = false;
     
               }
     
               if (firstRun == true)
                   count++;

    is also not at the right place. You can easily subscribe for the SelectedIndexChanged event in XAML.

    So, since I am still not quite sure that I correctly understand what you're trying to achieve, I would like to ask you for some further details and I will try to modify your project accordingly.

    Greetings,
    Deyan
    the Telerik team
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  7. Gian Paolo Santopaolo
    Gian Paolo Santopaolo avatar
    13 posts
    Member since:
    Mar 2010

    Posted 14 Mar 2013 Link to this post

    Never mind I solved the issue, I here is the working solution http://sdrv.ms/WpbVX8.
    Btw looping list is a great control !

    -g

Back to Top
DevCraft banner