SlideView containing listboxes

4 posts, 0 answers
  1. Richard
    Richard avatar
    8 posts
    Member since:
    Jun 2011

    Posted 29 Jul 2012 Link to this post

    Hi,

    Been trying to use the SlideView control with a listbox held within ItemTemplate/DataTemplate combination, however I'm running into serious memory issues as a result. I also can't seem to vertically scroll the listbox either, it does react however the scrolling is inverted, so starting to wonder whether the SlideView control is really designed for what I'm doing.

    The Listbox does contain 20-40 image-heavy items. I'm effectively trying to create a non-looping headerless pivot control. The SlideView has a total of 9 "pages".

    If this should technically work, then I can try and put together a sample project that demonstrates the issue.

    Any help would be greatefully received. Thank you.
    Richard
  2. Richard
    Richard avatar
    8 posts
    Member since:
    Jun 2011

    Posted 30 Jul 2012 Link to this post

    So after spending some time preparing an example, I discovered the issue. I had included a <stackpanel> container within the <DataTemplate> that held the listbox. As soon as I removed this, my memory issues stopped and the listbox scrolling started working as designed.

    Still not sure what was going on, but pleased that the problem has been resolved.

    Thanks,
    Richard
  3. DevCraft banner
  4. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 31 Jul 2012 Link to this post

    Hello Richard,

    When you refer to "memory issues" I believe you mean "high memory consumption" not "memory leaks"

    My theory why removing the StackPanel fixed your issues is the following. 
    Putting a virtualization control (ListBox, RadDataBoundListBox etc.) inside a StackPanel is not recommended. Before rendering, in its Measure pass, the StackPanel measures its children (ex. the ListBox in your scenario) with Infinity. That's basically saying to the ListBox:
     - "Here, take all the space in the world you need".
    If a ListBox (or any other control that supports virtualization) is given infinite amount of space to render, it will realize (create) all of its children. And the key to a successful virtualized control is: "Do not create more children than you have to" :).

    To finish off, the rule of thumb when dealing with virtualization is: Do not put a virtualization control inside a panel that measures its children with Inifiny (StackPanel, Grid.Row with Height=Auto and Grid.Column with Width=Auto (when virtualizing horizontally)).

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Richard
    Richard avatar
    8 posts
    Member since:
    Jun 2011

    Posted 31 Jul 2012 Link to this post

    Hi Kiril,

    Thank you for taking the time to post some explanation on what was happening. As you say, the issue was high memory consumption - I was topping out at 120mb and then crashing.

    The theory sounds absolutely right and explains why it looked like the listbox was inverted - what I was seeing was the elastic end stops operating on a listbox that didn't have a scrollbar (because of the stackpanel).

    Hopefully this post series will help others who make the same (foolish) mistake that I made!

    Regards,
    Richard
Back to Top