private void PreviewPage_Click(object sender, RoutedEventArgs e) //上一页 { if (this.Page == 1) { tipWindow warning = new tipWindow("已经是第一页了"); warning.ShowDialog(); return; } this.Page--; PageLabel.Text = "当前页面:" + Page.ToString(); switch (this.CurrentQList) { case 1: this.QuestionList = CommunityService.GetAllQuestions(Page); break; case 2: this.QuestionList = this.User.GetMyQuestions(this.Page); break; case 3: this.QuestionList = this.User.GetMyAnswers(this.Page); break; case 4: this.QuestionList = CommunityService.SearchQuestion(Keyword.Text, this.Page); break; } this.QuesItem.ItemsSource = null; this.QuesItem.ItemsSource = QuestionList; }
private void AllQuestion_Click(object sender, RoutedEventArgs e) //所有提问 { this.Page = 1; this.CurrentQList = 1; Keyword.Text = ""; PageLabel.Text = "当前页面:" + Page.ToString(); this.QuestionList = CommunityService.GetAllQuestions(Page); this.QuesItem.ItemsSource = null; this.QuesItem.ItemsSource = QuestionList; }
} //1:全部提问 2:我的提问 3:我的回答 4:搜索 public CommunityPage() { InitializeComponent(); this.CurrentQList = 1; this.Page = 1; PageLabel.Text = "当前页面:" + Page.ToString(); this.QuestionList = CommunityService.GetAllQuestions(Page); this.QuesItem.ItemsSource = QuestionList; // this.QuesItem.ItemsSource = QuestionList; // this.AnsItem.ItemsSource = AnswerList; // this.ques_info.DataContext = QuestionList[0]; }
private void NextPage_Click(object sender, RoutedEventArgs e) //下一页 { this.Page++; List <Question> qlist; bool isSuccess = true; switch (this.CurrentQList) { case 1: qlist = CommunityService.GetAllQuestions(Page); if (qlist == null) { isSuccess = false; break; } this.QuestionList = qlist; isSuccess = true; break; case 2: qlist = this.User.GetMyQuestions(this.Page); if (qlist == null) { isSuccess = false; break; } this.QuestionList = qlist; isSuccess = true; break; case 3: qlist = this.User.GetMyAnswers(this.Page); if (qlist == null) { isSuccess = false; break; } this.QuestionList = qlist; isSuccess = true; break; case 4: qlist = CommunityService.SearchQuestion(Keyword.Text, this.Page); if (qlist == null) { isSuccess = false; break; } this.QuestionList = qlist; isSuccess = true; break; } if (isSuccess == false) { this.Page--; tipWindow warning = new tipWindow("没有更多了"); warning.ShowDialog(); return; } PageLabel.Text = "当前页面:" + Page.ToString(); this.QuesItem.ItemsSource = null; this.QuesItem.ItemsSource = QuestionList; }