Beispiel #1
0
 private void OnItemAppearing(object sender, ItemVisibilityEventArgs e)
 {
     if (ItemAppearingCommand != null)
     {
         ItemAppearingCommand?.Execute(e.Item);
     }
 }
Beispiel #2
0
        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);
            }
        }
Beispiel #4
0
 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);
         }
     }
 }
Beispiel #5
0
 public override void SubscribeModel()
 {
     model.DayTableModels.ObserveAddChanged()
     .Subscribe(x =>
     {
         MainGroupListViewModel sameTitleViewModel = DayTableViewModels.FirstOrDefault(y => y.Title == x.Station);
         if (sameTitleViewModel != null)
         {
             sameTitleViewModel.Add(new DayTableViewModel(x));
         }
         else
         {
             DayTableViewModels.Add(new MainGroupListViewModel(x.Station)
             {
                 new DayTableViewModel(x)
             });
         }
     })
     .AddTo(Disposables);
     model.DayTableModels.ObserveResetChanged()
     .Subscribe(x => DayTableViewModels.Clear())
     .AddTo(Disposables);
     model.ObserveProperty(x => x.IsLoading)
     .Subscribe(x => isLoading.Value = x)
     .AddTo(Disposables);
     Observable.FromEventPattern <ErrorEventArgs>(h => model.ErrorOccurred += h, h => model.ErrorOccurred -= h)
     .Select(x => x.EventArgs)
     .Subscribe(x => ShowAlertCommand.Execute(x.Message))
     .AddTo(Disposables);
     LoadCommand.Subscribe(async _ => await model.LoadAsync())
     .AddTo(Disposables);
     LoadIfEmptyCommand.Subscribe(async _ => await model.LoadIfEmptyAsync())
     .AddTo(Disposables);
     ItemSelectedCommand.Subscribe(x => PushDayTableViewCommand.Execute(x.Clone()))
     .AddTo(Disposables);
     ItemAppearingCommand.Subscribe(x => x.SubscribeModel())
     .AddTo(Disposables);
     ItemDisappearingCommand.Subscribe(x => x.UnSubscribeModel())
     .AddTo(Disposables);
 }