Last active
March 19, 2017 14:32
-
-
Save rootasjey/5246ee11278e59560527dda559dcd8b2 to your computer and use it in GitHub Desktop.
uwp Semantic Zoom c# code-behind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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