Problem about the DataRequested in the DataBoundListbox

5 posts, 0 answers
  1. ellic
    ellic avatar
    16 posts
    Member since:
    Oct 2011

    Posted 14 Apr 2012 Link to this post

    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?


  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 16 Apr 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. ellic
    ellic avatar
    16 posts
    Member since:
    Oct 2011

    Posted 16 Apr 2012 Link to this post

    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.
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 17 Apr 2012 Link to this post

    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 >>

  6. ellic
    ellic avatar
    16 posts
    Member since:
    Oct 2011

    Posted 17 Apr 2012 Link to this post

    Thanks, Deyan

    I've got your point, and decided to use to a boolean flag to make everythig works fine.
Back to Top
DevCraft banner