Skip to content

Instantly share code, notes, and snippets.

@rootasjey
Last active March 19, 2017 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rootasjey/5246ee11278e59560527dda559dcd8b2 to your computer and use it in GitHub Desktop.
Save rootasjey/5246ee11278e59560527dda559dcd8b2 to your computer and use it in GitHub Desktop.
uwp Semantic Zoom c# code-behind
// This code works with SemanticZoom.xaml gist
// It show you how to bind data to a CollectionViewSource
// in order to use a SemanticView control
// NOTE: Author is a custom model I created in my code
// See the model definition here
// https://github.com/rootasjey/citations365/blob/master/Citations%20365/Citations%20365/Models/Author.cs
private void BindCollectionToView() {
// 1.You need a data list
ObservableCollection<Author> collection = new ObservableCollection<Author>();
// and fill the list with data: collection.Add(new Author() { ... ] );
// 2.You have to group data by a rule
var groupedAuthors = from author in collection
group author by author.Name.First() into firstLetter
orderby firstLetter.Key
select firstLetter;
// 3.Link the new grouped data
this.groupedAuthors.Source = groupedAuthors;
AuthorsKeys.ItemsSource = this.groupedAuthors.View.CollectionGroups;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment