kstanoev
2/25/2015 - 11:59 AM

Using the LoopingList for Windows Store Apps

Using the LoopingList for Windows Store Apps

// The LoopingList uses a LoopingListDataSource to improve the performance of the app throught UI virtualization.
// Items are created through an event only when needed.
// The event is called ItemNeeded.
// For example, the code below will create a looping list of day names
LoopingListDataSource src = new LoopingListDataSource(DateTimeFormatInfo.CurrentInfo.DayNames.Length);
IEnumerator dayEnumerator = DateTimeFormatInfo.CurrentInfo.DayNames.GetEnumerator();
src.ItemNeeded + = (sender, args) =>
{
	if (dayEnumerator.MoveNext())
	{
		args.Item = new LoopingListDataItem(dayEnumerator.Current.ToString());
	}
};