public QuestionsPage(int position = 0) : base() { InitializeComponent(); BindingContext = new QuestionsViewModel(position); var cancel = new ToolbarItem { Text = "添加", Command = new Command(async() => { if (UserTokenSettings.Current.HasExpiresIn()) { MessagingService.Current.SendMessage(MessageKeys.NavigateLogin); } else { await NavigationService.PushAsync(Navigation, new QuestionsEditPage(new Questions(), new Action <Questions>(OnResult))); } }) }; ToolbarItems.Add(cancel); if (Device.Android == Device.RuntimePlatform) { cancel.Icon = "toolbar_add.png"; } this.QuestionsListView.ItemSelected += async delegate { var questions = QuestionsListView.SelectedItem as Questions; if (questions == null) { return; } var questionsDetails = new QuestionsDetailsPage(questions); await NavigationService.PushAsync(Navigation, questionsDetails); this.QuestionsListView.SelectedItem = null; }; ViewModel.GetClientQuestionsAsync(); }
public QuestionsSearchPage() : base() { InitializeComponent(); BindingContext = new SearchViewModel(3); this.SearchsListView.ItemSelected += async delegate { var search = SearchsListView.SelectedItem as Search; if (search == null) { return; } var id = 0; if (int.TryParse(search.Uri.Substring(search.Uri.TrimEnd('/').LastIndexOf("/") + 1).TrimEnd('/'), out id)) { var questions = new Questions() { Qid = id, Title = search.Title, Content = search.Content, Award = 0, QuestionUserInfo = new QuestionUserInfo { UserName = search.UserName, IconName = search.UserAlias }, DateAdded = search.PublishTime, DiggCount = search.VoteTimes, AnswerCount = search.CommentTimes, ViewCount = search.ViewTimes }; var articlesDetails = new QuestionsDetailsPage(questions); await NavigationService.PushAsync(Navigation, articlesDetails); } this.SearchsListView.SelectedItem = null; }; }