Grouping
For the example of displaying a user’s photos, it’s natural to want to group them based on the day (or month or year) they were taken. To enable this, let’s first add an appropriate property to the Photo
class:
class Photo{ public ImageSource Thumbnail { get; set; } public DateTimeOffset DateTaken { get; set; } // More properties can be added as needed}
Then, the following code updates the SetDataContext
method shown previously with support for grouping the photos based on the day they were taken:
async Task SetDataContext(){ // This requires the Pictures Library capability StorageFolder pictures = KnownFolders.PicturesLibrary; foreach (StorageFile file in await pictures.GetFilesAsync()) ...
Get XAML Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.