private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) { if (scrollViewer.VerticalOffset >= scrollViewer.ScrollableHeight - LoadMoreBottomOffset && CanLoadMore) { LoadMoreCommand?.Execute(null); } }
public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) { if ((indexPath.Row >= (ItemsSource.Count() - FromBottomCellStartLoadingIndex)) && LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } }
private void MyAdaptiveGridView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Debug.WriteLine("内容变更"); if (scrollViewer.ScrollableHeight == 0) { LoadMoreCommand?.Execute(null); } }
private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { if (ItemAppearingCommand != null) { ItemAppearingCommand?.Execute(e.Item); } if (LoadMoreCommand != null) { if (IsGroupingEnabled) { if (PageSize == null) { var firstItem = ((IList)ItemsSource.Cast <object>().First()).Cast <object>().First(); if (e.Item == firstItem && !IsRefreshing) { LoadMoreCommand?.Execute(null); } } else { var firstItem = ((IList)ItemsSource.Cast <object>().First()).Cast <object>().First(); var totalItems = 0; foreach (var item in ItemsSource.Cast <object>()) { totalItems = totalItems + ((IList)item).Cast <object>().Count(); } if (e.Item == firstItem && !IsRefreshing & totalItems >= PageSize.Value) { LoadMoreCommand?.Execute(null); } } } else { if (PageSize == null) { if (e.Item == ItemsSource.Cast <object>().First() && !IsRefreshing) { LoadMoreCommand?.Execute(null); } } else { if (e.Item == ItemsSource.Cast <object>().First() && !IsRefreshing & ItemsSource.Cast <object>().Count() >= PageSize.Value) { LoadMoreCommand?.Execute(null); } } } } }
// If the new item that is appearing on the screen is the last one in the // collection, we execute the LoadMoreCommand so our ViewModel knows we // want to load more data for our user from the data service. private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { ItemAppearingCommand?.Execute(e.Item); //If its the last item execute command and load more data. if (e.Item == ItemsSource.Cast <object>().Last()) { LoadMoreCommand?.Execute(null); } }
void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { var items = AssociatedObject.ItemsSource as IList; if (items != null && e.Item == items[items.Count - 1]) { if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } } }
public override void ExecuteRefreshCommand() { if (IsBusy) { return; } groups.Clear(); OnPropertyChanged("Groups"); CanLoadMore = true; LoadMoreCommand.Execute(null); }
private void LoadMoreListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { if (ItemsSource is IList items && e.Item == items[items.Count - 1]) { if (CanLoadMore && LoadStatus == LoadMoreStatus.StatusHasData) { if (CanLoadMore && (LoadMoreCommand?.CanExecute(null) == true)) { LoadMoreCommand.Execute(null); } } } }
private void InfiniteListViewItemAppearing(object sender, ItemVisibilityEventArgs e) { var items = ItemsSource as IList; if ((items != null) && (items.Count >= ItemsPerPage) && (items.Count - 3 >= 0) && (e.Item == items[items.Count - 3])) { if ((LoadMoreCommand != null) && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } } }
private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { if (ItemsSource != null && e.Item != null) { var items = ItemsSource as IList; if (e.Item == items[items.Count - 1]) { var execute = LoadMoreCommand?.CanExecute(e); if (execute.HasValue && execute.Value) LoadMoreCommand?.Execute(e.Item); } } }
private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { if (ItemAppearingCommand != null) { ItemAppearingCommand?.Execute(e.Item); } if (LoadMoreCommand != null) { if (e.Item == ItemsSource.Cast <object>().Last()) { LoadMoreCommand?.Execute(null); } } }
void LoadMoreListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { var items = ItemsSource as IList; if (items != null && e.Item == items[items.Count - 1]) { if (CanLoadMore && LoadStatus == LoadMoreStatus.StausDefault) { if (CanLoadMore && (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null))) { LoadMoreCommand.Execute(null); } } } }
private void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { if (IsLoadingMore) { return; } if (ItemsSource is IList items && e.Item == items[items.Count - 1]) { if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } } }
protected override void OnApplyTemplate() { scrollViewer = GetTemplateChild("ScrollViewer") as ScrollViewer; scrollViewer.ViewChanged += ScrollViewer_ViewChanged; this.RegisterPropertyChangedCallback(LoadingProperty, new DependencyPropertyChangedCallback((obj, e) => { if (!Loading) { if (scrollViewer.ScrollableHeight == 0) { LoadMoreCommand?.Execute(null); } } })); base.OnApplyTemplate(); }
void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { byte visibleLoad = 1; var items = AssociatedObject.ItemsSource as IList; if ((items == null) || (items?.Count ?? 0) < visibleLoad || (e?.Item ?? null) == null) { return; } if (items.IndexOf(e?.Item ?? null) >= items.Count - (visibleLoad + 1)) { if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } } }
private void OnItemAppearing(object sender, ItemVisibilityEventArgs e) { var items = ItemsSource as IList; if (_isLoadingMore || items == null || items.Count == 0 || LoadMoreCommand == null || !LoadMoreCommand.CanExecute(e.Item)) { return; } // Hit the bottom if (e.Item == items[items.Count - 1]) { _isLoadingMore = true; LoadMoreCommand.Execute(null); _isLoadingMore = false; } }
private void ExtendedListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { try { if (ItemsSource is IList items && e.Item.Equals(items[items.Count - LoadPositionOffset])) { var param = LoadMoreCommandParameter ?? e.Item; if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(param)) { LoadMoreCommand.Execute(param); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { try { var items = ItemsSource as IList; if (items.Count > 0) { if (items != null && e.Item == items[items.Count - 1]) { if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } } } } catch (System.Exception ex) { } }
private void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e) { var items = ItemsSource as IList; if (items == null) { Log.Warn("ItemsSource needs to be of type IList, otherwise performance suffers to great"); return; } if (LoadMoreCommand == default(ICommand)) { return; } if (e.Item == items[items.Count - LoadMoreOffset] && LoadMoreCommand.CanExecute(e.Item)) { LoadMoreCommand.Execute(e.Item); } }
public LoadMoreListView() { ItemAppearing += (sender, args) => { IList items = ItemsSource as IList; if (items?.Count == 0 && LoadMoreCommand == null && !LoadMoreCommand.CanExecute(null)) { return; } if (args.Item == items[items.Count - 1]) { LoadMoreCommand.Execute(null); } }; Footer = new StackLayout { Spacing = 0, Padding = 12, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Children = { new ActivityIndicator { IsRunning = true, HeightRequest = 15, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Color = AppColor.MainAction } } }; }
public LoadMoreListView() : base(ListViewCachingStrategy.RecycleElement) { loadingPage = new StackLayout { Orientation = StackOrientation.Horizontal, HeightRequest = 50, Children = { new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { new ActivityIndicator { IsRunning = true, WidthRequest = 20, HeightRequest = 20, Color = (Color)Application.Current.Resources["Primary"], VerticalOptions = LayoutOptions.CenterAndExpand }, new Label { Text = "正在加载中", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } } } }; endPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "没有更多了", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; failPage = new StackLayout { HeightRequest = FailHeight, Children = { new StackLayout { VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "似乎出了点问题", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, HorizontalOptions = LayoutOptions.CenterAndExpand, }, new Label { Text = "重新加载", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, TextColor = (Color)Application.Current.Resources["Primary"], HorizontalOptions = LayoutOptions.CenterAndExpand, } } } } }; var failGestureRecognizer = new TapGestureRecognizer(); failGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausFail) { RefreshCommand.Execute(null); } }; failPage.GestureRecognizers.Add(failGestureRecognizer); nodataPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "还没有内容", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; errorPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "加载失败,点击重试", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; var errorGestureRecognizer = new TapGestureRecognizer(); errorGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausError && LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } }; errorPage.GestureRecognizers.Add(errorGestureRecognizer); nologinPage = new StackLayout { HeightRequest = FailHeight, Children = { new StackLayout { VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "还未登录", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, HorizontalOptions = LayoutOptions.CenterAndExpand, }, new Label { Text = "马上登录", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, TextColor = (Color)Application.Current.Resources["Primary"], HorizontalOptions = LayoutOptions.CenterAndExpand, } } } } }; var nologinGestureRecognizer = new TapGestureRecognizer(); nologinGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausNologin) { MessagingService.Current.SendMessage(MessageKeys.NavigateLogin); } }; nologinPage.GestureRecognizers.Add(nologinGestureRecognizer); ItemAppearing += LoadMoreListView_ItemAppearing; }
public LoadMoreListView() : base(ListViewCachingStrategy.RecycleElement) { Xamarin.Forms.PlatformConfiguration.iOSSpecific.ListView.SetSeparatorStyle(this, Xamarin.Forms.PlatformConfiguration.iOSSpecific.SeparatorStyle.FullWidth); loadingPage = new StackLayout { Orientation = StackOrientation.Horizontal, HeightRequest = 50, Children = { new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { new ActivityIndicator { IsRunning = true, WidthRequest = 20, HeightRequest = 20, Color = (Color)Application.Current.Resources["Primary"], VerticalOptions = LayoutOptions.CenterAndExpand }, new Label { Text = "Loading...", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } } } }; endPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "No more", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; failPage = new StackLayout { HeightRequest = FailHeight, Children = { new StackLayout { VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "It seems that something went wrong.", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, HorizontalOptions = LayoutOptions.CenterAndExpand, }, new Label { Text = "Reload", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, TextColor = (Color)Application.Current.Resources["Primary"], HorizontalOptions = LayoutOptions.CenterAndExpand, } } } } }; var failGestureRecognizer = new TapGestureRecognizer(); failGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausFail) { RefreshCommand.Execute(null); } }; failPage.GestureRecognizers.Add(failGestureRecognizer); nodataPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "No content yet", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; errorPage = new StackLayout { HeightRequest = 50, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "Failed to load, click to try again", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, VerticalOptions = LayoutOptions.CenterAndExpand } } }; var errorGestureRecognizer = new TapGestureRecognizer(); errorGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausError && LoadMoreCommand != null && LoadMoreCommand.CanExecute(null)) { LoadMoreCommand.Execute(null); } }; errorPage.GestureRecognizers.Add(errorGestureRecognizer); nologinPage = new StackLayout { HeightRequest = FailHeight, Children = { new StackLayout { VerticalOptions = LayoutOptions.EndAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "Not logged in yet", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, HorizontalOptions = LayoutOptions.CenterAndExpand, }, new Label { Text = "Log in now", Style = Application.Current.Resources["SecondaryTextStyle"] as Style, TextColor = (Color)Application.Current.Resources["Primary"], HorizontalOptions = LayoutOptions.CenterAndExpand, } } } } }; var nologinGestureRecognizer = new TapGestureRecognizer(); nologinGestureRecognizer.Tapped += (s, e) => { if (LoadStatus == LoadMoreStatus.StausNologin) { MessagingService.Current.SendMessage(MessageKeys.NavigateLogin); } }; nologinPage.GestureRecognizers.Add(nologinGestureRecognizer); ItemAppearing += LoadMoreListView_ItemAppearing; }