O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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()) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required