Hi I have a program which is goin to basically load news articles from an IEnumerable. I have started a method which has to load only the first item in this IEnumerable. Then on a user gesture ( swipe-left or swipe-right) the previous item or next item in the IEnumerable will be loaded. Also if the user tries to load an index out of range item ( for example -1 or an item that is greater that the count of the IEnumerable) it will do nothing.
I have written many methods that iterate through an IEnumerable but i found some difficulty trying to solve this one :/
Convert the enumerable to a List first by calling ToList. You can then keep track of the current index and act accordingly.
Edit: If you want items to “load” only when needed, you could wrap each item in a Lazy. That way, you can materialize the whole list, but only load individual items when required. This will also load an item only once even when the user flicks back and forth.