I have a listbox and it's source is Binded to a XmlDataProvider. and a RSS link for the source of XmlDataProvider. It's all working correctly, getting feeds and displaying them in the listbox. I have a DispatcherTimer in the code that Refresh the XmlDataProvider source every 10 minutes. Now All I need is to count the new items added in the ListBox in each Refresh Interval.
Can anyone help me to implement a way to count only new items added in the listbox in each Refresh Time Interval? Please Help.
I agree with "before adding the item to list count it. – Shujaat Siddiqui", but also you cold add Linq or For cicle, to check if ID of the Item already exists, and count the unique ones. Something like:
More detailed:
First time when you get the news, you do something like this:
For example you have some model for your news:
And you get your news like:
List news = XML.Deserialize(response.GetResponse()) // can't remember by memory, but this is your response from server deserialized using XML deserializer
Then you populate your ListBox with List news, like this:
Now you get the update from the server:
List news = XML.Deserialize(response.GetResponse()) // can't remember by memory, but this is your response from server deserialized using XML deserializer
Now you should check how much new items were added ( before adding new items to ListBox ), you should do something like:
a) if you used ListBox.DataSource = news
After this code ran you can use newUniqueNewsCount to show the new items count in UI.