private async Task LoadBook() { BookContext bc = new BookContext(); this.Book = await bc.Load(); TopChapters = new ObservableCollection <Chapter>(); var filterResult = this.Book.Chapters.Take(10); foreach (var chapter in filterResult) { TopChapters.Add(chapter); } ChapterGroup group = null; for (int i = 0; i < this.Book.Chapters.Count; i++) { if (group == null) { group = new ChapterGroup() { Key = (i + 1).ToString() + "~" + (i + chapterGroupSize).ToString() }; ChapterGroups.Add(group); } group.Chapters.Add(this.Book.Chapters[i]); if (((i + 1) % chapterGroupSize) == 0) { group = null; } } }
private async Task LoadBook() { BookContext bc = new BookContext(); this.Book = await bc.Load(); TopChapters = new ObservableCollection<Chapter>(); var filterResult = this.Book.Chapters.Take(10); foreach (var chapter in filterResult) { TopChapters.Add(chapter); } ChapterGroup group=null; for (int i = 0; i < this.Book.Chapters.Count; i++) { if (group==null) { group = new ChapterGroup() { Key = (i + 1).ToString() + "~" + (i+chapterGroupSize).ToString() }; ChapterGroups.Add(group); } group.Chapters.Add(this.Book.Chapters[i]); if (((i+1) % chapterGroupSize)==0) { group = null; } } }