Esempio n. 1
0
        public async void LoadComments(News news)
        {
            Pb.Visibility = Visibility.Visible;

            if (news != null)
            {
                if (NetworkService.IsNetworkAvailable() == false)
                {
                    await new DialogService().ShowError("请检查网络连接。", "错误", "关闭", null);
                }
                else
                {
                    Exception exception = null;
                    try
                    {
                        var comments = await news.CommentAsync(1, int.MaxValue);

                        var index             = 0;
                        var commentsWithIndex = from temp in comments
                                                select new
                        {
                            Index   = ++index,
                            Comment = temp
                        };
                        Lv.ItemsSource = commentsWithIndex;
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                    }
                    if (exception != null)
                    {
                        await new DialogService().ShowError(exception, "错误", "关闭", null);
                    }
                }
            }

            Pb.Visibility = Visibility.Collapsed;
        }