Strange ItemTemplate behavior

8 posts, 0 answers
  1. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 10 Jul 2013 Link to this post

    Hi, we're experiencing strange behavior when using SlideView for image gallery with custom ItemTemplate/UserControl. We've discovered, that UserControl instances are not recycled/used in deterministic order, but rather somehow in random.

    Example, If I got collection of 5 images, that is displayed using SlideView
    Default situatio is 

    (no preceding page)
    Img1 shown using 1st UserControl instance
    Img2 preloaded using 2nd UserControl instance

    When I scroll to the right, the expected situation is
    Img1 preloaded using 1st UserControl instance
    Img2 shown using 2nd UserControl instance
    Img3 preloaded using 3rd UserControl instance

    But the observed behavior after scrolling to the right is 
    Img1 preloaded using 2nd UserControl instance
    Img2 shown using 3rd UserControl instance
    Img3 preloaded using 1st UserControl instance


    This is is causing flickering effect when scrolling between pages, because DataContext of all UserControl instances is changed.
    Am I doing something wrong, or this is expected behavior. Could it be fixed somehow?
    Thanks

    Edit: the intention here is simple, when I open the page with SlideView and the 1st and 2nd page is fully loaded, I scroll form page 1 to 2, I don't want the 2nd page load again just because internally another UserControl is shown for the 2nd page. I want to see the already preloaded usercontrol for the 2nd page.
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 11 Jul 2013 Link to this post

    Hi Mirco,

    Thank you for writing.

    The behavior that you have explained is expected with the current implementation of RadSlideView. However, we are in the process of modifying the approach we use to load the items. Indeed, when the selection is changed, there is no need to load all three items again, but only the one(s) that haven't been loaded yet.

    The update in RadSlideView will become part of our Service Pack release, scheduled for next week, so stay tuned and look for the update. 

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 11 Jul 2013 Link to this post

    Hi, I've created simple demonstration project, where this issue is clearly seen - SlideView vs Panorama. The ItemTemplate instances are just randomly rearrange after each page change. When testing check also the Output window, that is shown used itemTemplates when swiping.

    Because of this bug we currently cannot use this control anywhere in our app, but I appreciate that update will be available soon, thanks.

    http://sdrv.ms/16tDboA
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 16 Jul 2013 Link to this post

    Hello Mirko,

    Thank you for sending a sample project.

    It was useful for us to confirm that the Service Pack that we are releasing later this week will be helpful for your scenario as well.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 18 Jul 2013 Link to this post

    Thanks, it works now as expected.
    Maybe I got another one question, would it be possible in SlideView to recycle only three ItemTemplate instances (as an option) instead of creating new instance every time new page should be preloaded?
  7. Todor
    Admin
    Todor avatar
    778 posts

    Posted 19 Jul 2013 Link to this post

    Hello Mirko,

    RadSlideView uses three containers to load the selected item and its adjacent items. However, the template that is used to display them might not be the same and this is why we prefer to evaluate it each time when the selection is changed. This is necessary since the ItemTemplateSelector property allows you to use different templates depending on the data that is currently displayed. The ItemPreviewTemplate property also allows you to use different templates: one the selected item and another for the adjacent items. These usages would conjunct with an option that would allow you to reuse the template and might lead to unexpected behavior in many cases.

    However, if you provide some more details about your scenario and show us if the current implementation of RadSlideView puts some limitations and restricts you to achieve your desired behavior we may consider adding such an option.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  8. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 30 Jul 2013 Link to this post

    Hi,
    the idea for recycling only three ItemTemplate instances is simple:

    The expected behavior I'd like to have:

    (no preceding page)
    Img1 shown using 1st UserControl instance
    Img2 preloaded using 2nd UserControl instance
    When I scroll to the right, the expected situation is
    Img1 preloaded using 1st UserControl instance
    Img2 shown using 2nd UserControl instance
    Img3 preloaded using 3rd UserControl instance
    After next scrolling to the right:
    Img2 preloaded using 2nd UserControl instance
    Img3 shown using 3rd UserControl instance
    Img4 preloaded using 1st UserControl instance
    After next scrolling to the right:
    Img3 preloaded using 3rd UserControl instance
    Img4 shown using 1st UserControl instance
    Img5 preloaded using 2nd UserControl instance

    The current behavior I see:
    (no preceding page)
    Img1 shown using 1st UserControl instance
    Img2 preloaded using 2nd UserControl instance
    When I scroll to the right, the expected situation is
    Img1 preloaded using 1st UserControl instance
    Img2 shown using 2nd UserControl instance
    Img3 preloaded using 3rd UserControl instance
    After next scrolling to the right:
    Img2 preloaded using 2nd UserControl instance
    Img3 shown using 3rd UserControl instance
    Img4 preloaded using 4th UserControl instance
    After next scrolling to the right:
    Img3 preloaded using 3rd UserControl instance
    Img4 shown using 4th UserControl instance
    Img5 preloaded using 5th UserControl instance


    You can imagine if the UserControl uses several megabytes of memory, or even it contain 3rd party component (like Ad banner), that is memory leaking, this can lead to serious problems.
    Adding this functionality as third ItemRealizationMode should not be hard in my opinion and it would help us a lot.
    Thanks.

    Edit: just found another bug, if you swipe between SlideView items, go forward to another app page and go back, ItemTemplate for different item from the ItemsSource is shown. I've udpated the sample with reproduction scenario for this bug here (SlideViewBug2): 
    http://sdrv.ms/12BWAYJ  follow the steps in "SlideViewPageHtml.xaml.cs"
  9. Todor
    Admin
    Todor avatar
    778 posts

    Posted 02 Aug 2013 Link to this post

    Hello Mirko,

    When you scroll to the right and the Img4 is loaded in the 4th UserControl instance, the 1st UserControl instance will be no longer necessary and the memory it consumes will be eventually regained by the GarbageCollector. However, if you have experienced such memory leaks please let us know.

    As to the issue when navigating back, I was able to reproduce it and I can confirm that it will be fixed with the next internal build.

    Thank you for reporting it and for your continuous cooperation. I have updated your Telerik points accordingly.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner