Async Image Binding

2 posts, 0 answers
  1. lee
    lee avatar
    14 posts
    Member since:
    Nov 2010

    Posted 15 Nov 2012 Link to this post

    I have created a class AsyncClass and
    Receives as an argument the path to the file has one of the Image property.
    Default file loaded into memory before the image from the Image properties
    Return when you load the file into memory and returns the file loaded in the Image properties

    At the time the file is loaded I want to change the image of the ListView's Row informs this possible?
    (like wpf binding  )

    private void radListView1_ItemDataBound(object sender, Telerik.WinControls.UI.ListViewItemEventArgs e)
                DataRowView rowView = e.Item.DataBoundItem as DataRowView;
                AsyncImage ai = new AsyncImage(rowView["FilePath"].ToString());
                e.Item.Image = AsyncImage.Image;
  2. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 16 Nov 2012 Link to this post

    Hi Lee,

    Thank you for your question.

    RadListView updates the images of its items when you set the their Image property. This means that if you use:
    AsyncImage ai = new AsyncImage(rowView["FilePath"].ToString());
    e.Item.Image = AsyncImage.Image;

    and at the second step the image is not yet loaded, RadListView will not display it when it completes loading, because no notification will be sent. You need to implement a method or an event handler in your AsyncImage class which notifies the RadListView when an image has finished loading. To update RadListView, either reset the Image property of the corresponding item;
    e.Item.Image = null;
    e.Item.Image = AsyncImage.Image;

    or use the following method:

    I hope this will help you. Do not hesitate to ask if you have additional questions.

    All the best,
    Ivan Todorov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top