private async void RefreshGames()
        {
            try
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    OnlineProgressText.Text = "Loading games";
                });

                var games = await fics.ListGames();

                foreach (GameType gameType in Enum.GetValues(typeof(GameType)))
                {
                    List<dynamic> gameTexts = new List<dynamic>();
                    ListView listView = gameTypeGameLists[gameType];

                    foreach (var game in games.Where(g => g.Type == gameType).OrderByDescending(g => g.WhitePlayer.Rating + g.BlackPlayer.Rating))
                    {
                        dynamic text = new ToStringExpandoObject();

                        text.ToString = new ToStringFunc(() =>
                        {
                            if (game.Private)
                                return string.Format("Private --- {4}: {0} ({1})  VS  {2} ({3})", game.WhitePlayer.Username, game.WhitePlayer.RatingString, game.BlackPlayer.Username, game.BlackPlayer.RatingString, game.Rated ? "Rated" : "Unrated");
                            return string.Format("{4}: {0} ({1})  VS  {2} ({3})", game.WhitePlayer.Username, game.WhitePlayer.RatingString, game.BlackPlayer.Username, game.BlackPlayer.RatingString, game.Rated ? "Rated" : "Unrated");
                        });
                        text.Game = game;
                        gameTexts.Add(text);
                    }

                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        listView.ItemsSource = gameTexts;
                    });
                }

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    foreach (var typeGame in gameTypeGameLists)
                    {
                        UpdateGamesListItem(typeGame);
                    }

                    firstOnelineGamesLoaded = true;

                    if (OnlineGames)
                    {
                        OnlineGamesPanel.Visibility = Visibility.Visible;
                        OnlineProgressPanel.Visibility = Visibility.Collapsed;
                    }
                });
            }
            catch (Exception ex)
            {
            }

            var t = Task.Run(async () =>
            {
                await Task.Delay(5000);
                RefreshGames();
            });
        }
        private void UpdateGamesListItem(KeyValuePair<GameType, ListView> typeGame)
        {
            dynamic text = new ToStringExpandoObject();

            text.ToString = new ToStringFunc(() =>
            {
                return string.Format("{0} ({1})", typeGame.Key, typeGame.Value.Items.Count);
            });
            text.GameType = typeGame.Key;

            int selected = OnlineGamesList.SelectedIndex;

            for (int i = 0; i < OnlineGamesList.Items.Count; i++)
            {
                dynamic t = OnlineGamesList.Items[i];

                if (t.GameType == text.GameType)
                {
                    OnlineGamesList.Items[i] = text;
                    if (selected == i)
                    {
                        OnlineGamesList.SelectedIndex = selected;
                    }
                    return;
                }
            }

            OnlineGamesList.Items.Add(text);
        }