Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding items to List<> of object which already contain data, add duplicate item in the List
    primarykey
    data
    text
    <p>I am developing a Windows phone app for which I want to get a list of first 15 object from my web service plus an extra item to represent the "Load next 15 items button" and bind it to a listbox. On selection of the last element or index(buttton), I want to remove the last item(button) from the list and call the service again to get the next 15 items plus the button item which will again add up to the current list without clearing the list. And the same process goes on as we select the last item from the listbox. My problem is I am able to get it correctly for the first round. In the second round, the next 15 element is added to the list twice. I don't know what is the real problem. I am not getting any error or exception also.</p> <p>Below is what I have done so far :</p> <pre><code>private void ListBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { int LastIndex=app.imgItem.Count - 1; if (ListBox1.SelectedIndex == LastIndex) { app.imgItem.Remove(app.imgItem[app.imgItem.Count-1]); proxy.SelectNextItemsCompleted += new EventHandler&lt;ServiceReference1.SelectNextItemsCompletedEventArgs&gt;(proxy_SelectNextItemsCompleted); int id = app.imgItem.Last().Id; proxy.SelectNextItemsAsync(categoryID, id); } } void proxy_SelectNextItemsCompleted(object sender, ServiceReference1.SelectNextItemsCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show("Cannot load data."); return; } else { foreach (var item in e.Result) { ImgData idata = new ImgData(); idata.CategoryID = item.CategoryID; idata.ImageID = item.ImageID; idata.ImageTitle = item.ImageTitle; idata.Thumbnail = item.Thumbnail; app.imgItem.Add(idata); } } ImageData btnData = new ImageData(); btnData.CategoryID = 0; btnData.ImageID = 0; btnData.ImageTitle = ""; btnData.Thumbnail = "Images/loadButton.jpg"; app.imgItem.Add(btnData); ListBox1.ItemsSource = app.imgItem; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload