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

Memory consumption with large set of MultiScaleImages

1 Answer 46 Views
Book
This is a migrated thread and some comments may be shown as answers.
tobmatth
Top achievements
Rank 1
tobmatth asked on 21 Feb 2011, 11:56 AM
Hey there,

i have a simple book application with a MultiScaleImage control on each page. The larger the collection of MSICs, the more memory will be taken up. Is there any built in way to let's say have only 6 pages loaded at a time and dynamically load / unload on page flip?

Thanks,
Tobias

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 24 Feb 2011, 08:43 AM
Hi Tobias,

At any given moment there are no more than 10 pages within RadBook that are being rendered. No matter if your collection consists of 100 or 1000 items. In your particular scenario, I am not sure what will be the memory consumption when there are 10 MultiScaleImage controls.

Currently RadBook does not offer load on demand functionality out of the box (similar to RadTreeView). However, in scenarios like yours, such functionality makes sense so I'll add an item in our public issue tracking system under the name "Book: Load on demand support" which will be available for tracking and voting tomorrow the latest.

Bellow is one possible way to implement load on demand:

MainPage.xaml
<UserControl x:Class="SilverlightApplication1.MainPage"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadBook x:Name="book1" Width="500" Height="500" PageChanged="book1_PageChanged">
            <telerik:RadBook.ItemTemplate>
                <DataTemplate>
                    <Border Background="LightGray">
                        <TextBlock Text="{Binding Title}" HorizontalAlignment="Center"
                                VerticalAlignment="Center" FontSize="36" />
                    </Border>
                </DataTemplate>
            </telerik:RadBook.ItemTemplate>
        </telerik:RadBook>
    </Grid>
</UserControl>

MainPage.xaml.cs
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls;
 
namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        private ObservableCollection<Page> pages;
 
        public MainPage()
        {
            InitializeComponent();
            pages = new ObservableCollection<Page>(Enumerable.Range(0,6).Select(i => new Page() { Title = "Page " + i.ToString() }));
            book1.ItemsSource = pages;
        }
 
        private void book1_PageChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if(book1.RightPageIndex == pages.Count - 1)
            {
                pages.Add(new Page() { Title = "Page " + (pages.Count).ToString() });
                pages.Add(new Page() { Title = "Page " + (pages.Count + 1).ToString() });
                pages.Add(new Page() { Title = "Page " + (pages.Count + 2).ToString() });
                pages.Add(new Page() { Title = "Page " + (pages.Count + 3).ToString() });
                pages.Add(new Page() { Title = "Page " + (pages.Count + 4).ToString() });
                pages.Add(new Page() { Title = "Page " + (pages.Count + 5).ToString() });
            }
        }
    }
}

Page.cs
namespace SilverlightApplication1
{
    public class Page
    {
        public string Title { get; set; }
    }
}

Let me know how I can be of further assistance.

Best wishes,
Kiril Stanoev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Book
Asked by
tobmatth
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or