Virtualized datasource

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    26 posts
    Member since:
    Sep 2011

    Posted 19 Dec 2011 Link to this post

    I haven't played with this control much but when I tried I wasn't able to achieve my goal. Am I able to set up an infinite virtual datasource for the control? What I would like to do is a gallery of online images and as the user swipes through them it pulls the next image from online. For my data I would prefer to use an observablecollection which would be used as the datasource for the control. Is any of this possible or on the road map?

    Robert
  2. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 20 Dec 2011 Link to this post

    Hi Robert,

    Thank you for contacting us and for your question.

    RadSlideView inherits RadLoopingList and it is fully virtualized both in terms of UI and Data. The scenario with a gallery displaying online images should be easily implemented as the Silverlight framework itself handles image download and processing asynchronously and all you need to do is specify a valid URI. Here is a sample code:

    private void SetupSlideView()
    {
        // create a datasource with a virtual count of 100 000 to simulate infinite source
        int count = 100000;
        LoopingListDataSource source = new LoopingListDataSource(count);
        source.ItemNeeded += ((sender, e) =>
            {
                e.Item = new PictureDataItem();
            });
        source.ItemUpdated += ((sender, e) =>
        {
            (e.Item as PictureDataItem).Source = new Uri(this.pictures[e.Index % this.pictures.Length], UriKind.Absolute);
        });
     
        this.slideView.DataSource = source;
        this.slideView.IsLoopingEnabled = false;
    }

    Depending on the logical index you may dynamically build the URI and pass it as a Source property of the provided data item.

    And we need to specify proper ItemTemplate to display the image:

    <telerik:RadSlideView.ItemTemplate>
        <DataTemplate>
            <Image Source="{Binding Source}" Stretch="Uniform"/>
        </DataTemplate>
    </telerik:RadSlideView.ItemTemplate>

    We will think of a more generic data virtualization mechanism where you will be able to receive additional event - e.g. NewDataNeeded which will allow you to retrieve new data dynamically and to change the virtualized Count property of the data source depending on the downloaded data.

    Another solution would be to use the predefined SlideViewPictureSource where you can specify a collection of URIs/strings to download images from. Here is a sample code:

    <telerik:RadSlideView x:Name="slideView">
        <telerik:RadSlideView.DataSource>
            <telerik:SlideViewPictureSource ItemsSource="{Binding Pictures}"/>
        </telerik:RadSlideView.DataSource>
    </telerik:RadSlideView>

    I hope this helps. Let me know if I can assist you further.

    All the best,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Andrew
    Andrew avatar
    26 posts
    Member since:
    Sep 2011

    Posted 20 Dec 2011 Link to this post

    This doesn't really do what I was hoping. What I would expect is that slideview/radlooplist inherit from raddataboundlistbox and work the same with the exception that you could make it loop when DataVirtualizationMode is None. The control as it is now isn't useful for generic scenarios, only when you know the exact data you plan to display.

    Robert
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 23 Dec 2011 Link to this post

    Hi Robert,

     As Georgi explained, RadSlideView currently does not support on-demand data out of the box. We will consider implementing this feature in a future release.

    Thank you for the feedback and let us know if you have other questions.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top