Question

Using CollectionViewSource, is there a "direct" way of knowing if the current record is last one, without doing the comparatively heavy operation of enumerating through all the items to count them (even LINQ would do the same)? I need to enable/disable my navigation buttons depending upon the current position.

Was it helpful?

Solution

No, there is no direct way of determining whether the its that is current is the last one. A simple Linq Last() on the collection view will find you the last item. Please note, that the Linq Last will not necessarily enumerate the entire collection. If the collection being enumerated supports the IList interface or similar it will be able to locate the last item directly - see the example implementation here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top