public async void LoadCategory(int index) { VirtPanel.ClearItems(); if (_currentCategory == RecentsCategoryIndex) { UnloadRecents(); } if (index == RecentsCategoryIndex) { LoadRecents(); return; } List <VListItemBase> sprites = null; switch (index) { case 0: sprites = _category1Sprites; break; case 1: sprites = _category2Sprites; break; case 2: sprites = _category3Sprites; break; case 3: sprites = _category4Sprites; break; case 4: sprites = _category5Sprites; break; } if (sprites == null) { sprites = new List <VListItemBase>(); for (var i = 0; i < EmojiData.SpritesByCategory[index].Length; i++) { //var item = new EmojiSpriteItem(index, i); var item = new EmojiSpriteItem(EmojiData.SpritesByCategory[index][i], index, i); item.EmojiSelected += OnEmojiSelected; sprites.Add(item); } switch (index) { case 0: _category1Sprites = sprites; break; case 1: _category2Sprites = sprites; break; case 2: _category3Sprites = sprites; break; case 3: _category4Sprites = sprites; break; case 4: _category5Sprites = sprites; break; } } CurrentCategory = index; VirtPanel.AddItems(new List <VListItemBase> { sprites[0] }); CreateButtonsBackgrounds(index); if (!_wasRendered) { // Display LoadingProgressBar only once LoadingProgressBar.Visibility = Visibility.Collapsed; _wasRendered = true; } // Delayed rendering of the rest parts - speeds up initial load await Task.Delay(100); if (_currentCategory != index) { return; } var listList = sprites.ToList(); listList.RemoveAt(0); VirtPanel.AddItems(listList); }
/// <summary> /// Clear current highlight on scroll /// </summary> private static void VirtPanelOnScrollPositionChanged(object sender, MyVirtualizingPanel.ScrollPositionChangedEventAgrs scrollPositionChangedEventAgrs) { EmojiSpriteItem.ClearCurrentHighlight(); }