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

Async Image Binding

1 Answer 204 Views
ListView
This is a migrated thread and some comments may be shown as answers.
lee
Top achievements
Rank 1
lee asked on 15 Nov 2012, 06:31 AM
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;
 }

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 16 Nov 2012, 03:15 PM
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:
this.radListView1.ListViewElement.SynchronizeVisualItems();

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.
Tags
ListView
Asked by
lee
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Share this question
or