private void FeedsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { BindingExpression articleBinding = ArticlesListView.GetBindingExpression(ListView.ItemsSourceProperty); int tempIndex = FeedsListView.SelectedIndex; SelectedFeed.headline.Clear(); for (int i = 0; i < ListHeadList[tempIndex].Count; i++) { SelectedFeed.headline.Add((ListHeadList[tempIndex])[i]); } }
// GET: Articles public ActionResult Index(int page = 1, int take = 10) { if (page < 1) { page = 1; } ArticlesListView viewModel = new ArticlesListView(); var articlesQuery = db.Articles; viewModel.Articles = AutoMapper.Mapper.Map <List <ArticleView> >(articlesQuery.OrderBy(a => a.CreatedTime).Skip((page - 1) * take).Take(take).ToList()); viewModel.Articles.ForEach(a => a.CanEditOrDelete = User.Identity.IsAuthenticated && (a.CreatedUserId == User.Identity.GetUserId() || User.IsInRole("Admin") || User.IsInRole("Moderator"))); viewModel.PageCount = Math.Ceiling(articlesQuery.Count() / 10.0d); viewModel.CurrentPage = page; return(View(viewModel)); }
public ActionResult Search(string query, int page = 1) { var list = new ArticlesListView() { Articles = AutoMapper.Mapper.Map <List <ArticleView> >(db.Articles.Where(a => a.MainContent.Contains(query) || a.ShortBrief.Contains(query) || a.Title.Contains(query)).ToList()), CurrentPage = 1, PageCount = 1 }; var searchView = new SearchView { ArticlesListView = list, Query = query }; return(View(searchView)); }
public void GoTop() { ArticlesListView.ScrollIntoView(((IncrementalLoadingCollection <ArticleSource, ArticleViewModel>)ArticlesListView.ItemsSource)[0]); }
/// <summary> /// Sets the ViewModel.CurrentArticle property to the clicked item. /// </summary> /// <remarks> /// The ArticlesListView.ItemsSource property must be bound to a property /// of type Object, so it is bound to ViewModel.CurrentArticleAsObject. /// Making this a two-way binding would require a CurrentArticleAsObject /// setter that updates CurrentArticle. However, CurrentArticle must /// raise the PropertyChanged event with every setter call (not just ones /// that change its value), which causes an infinite recursion. The easiest /// way to prevent this is to use a one-way binding, and update CurrentArticle /// in this ItemClick event handler. /// </remarks> private void ArticlesListView_ItemInvoked(object sender, ListViewItem listViewItem) => ViewModel.CurrentArticle = ArticlesListView.ItemFromContainer(listViewItem) as ArticleViewModel;