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

Problem about the DataRequested in the DataBoundListbox

4 Answers 61 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ellic
Top achievements
Rank 1
ellic asked on 14 Apr 2012, 10:58 AM
I do like the DataRequested event in the DataBoundListBox, so I use it to show some ObservableCollection<Item> items object. But the Datarequested event seems to not work properly. The scenarios is that:
At first the App loads some local ObservableCollection<Item> items which stored in the isolatedstorage, and sets the ItemSource of the DataBoundListBox by 
mainpageList.ItemsSource = items

Then, the App will fetch some web resource and transform this resource into a ObservableCollection<Item> items object,  and use the code belowed to refresh the DataBoundListBox itemsource:
items.Clear();
 
 foreach (Item item in callbackItems)
 {
     items.Add(item);
 }
 
 mainpageList.ItemsSource = null;
 mainpageList.ItemsSource = items;

Then the problem comes, it's supposed that the DataRequested  event willn't fire until the ListBox is pulled down to the bottom, but when I modify the ItemsSource of the DataBoundListBox, it'll fire.

So I'm wondering is there anything I've done wrong?


4 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 16 Apr 2012, 11:46 AM
Hello Ellic,

 Indeed it is strange that the DataRequested event is fired when the collection is cleared. We will further research with the development team whether this is by design and implement a fix if necessary. Meanwhile, please take a look at the attached project which demonstrates one possible workaround for your scenario. Let me know if you have additional questions or comments. I'd be glad to further assist you.

Greetings,
Kiril Stanoev
the Telerik team

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

0
ellic
Top achievements
Rank 1
answered on 16 Apr 2012, 12:25 PM
Hi Kiril,

Thanks for your reply. I'm looking foward to your  bug-fix for the DataBoundListBox.

I'll just check the attached project to find if it works for me.


Thanks.
0
Deyan
Telerik team
answered on 17 Apr 2012, 09:44 AM
Hello Ellic,

This is a quick follow up with some further information regarding the DataRequested issue.

We have designed RadDataBoundListBox to fire this event each time a change occurs that implies inserting additional items into your data source collection. Similar cases might  be collection changes that lead to the realization of additional viewport space or simply scrolling to the end of the scrollable list.

In this context, we do not consider the current behavior as erroreous.

In your particular case, you could use a boolean flag to stop the execution of the logic in the DataRequested handler when you clear your source collection.

I hope this helps.

Let me know in case you have further questions or need assistance.

All the best,
Deyan
the Telerik team

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

0
ellic
Top achievements
Rank 1
answered on 17 Apr 2012, 09:50 AM
Thanks, Deyan

I've got your point, and decided to use to a boolean flag to make everythig works fine.
Tags
DataBoundListBox
Asked by
ellic
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
ellic
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or