Exemple #1
0
        public async override void Execute(object parameter)
        {
            base.Execute(parameter);

            LoadMoreDataContext context = (LoadMoreDataContext)parameter;

            LoadOnDemandCommand.ViewModel viewModel = (LoadOnDemandCommand.ViewModel)context.DataContext;
            this.lodCounter++;

            if (this.lodCounter % 3 == 0)
            {
                // If we do not need to get new data asynchronously, we can add the new items right away.
                viewModel.AddItems(15);
            }
            else
            {
                // If we need to get new data asynchronously, we must manually update the loading status.

                this.Owner.ChangeDataLoadingStatus(BatchLoadingStatus.ItemsRequested);

                // Mimic getting data from server asynchronously.
                await Task.Delay(2000);

                viewModel.AddItems(15);

                this.Owner.ChangeDataLoadingStatus(BatchLoadingStatus.ItemsLoaded);
            }
        }
Exemple #2
0
        public override bool CanExecute(object parameter)
        {
            LoadMoreDataContext context = (LoadMoreDataContext)parameter;

            LoadOnDemandCommand.ViewModel viewModel = (LoadOnDemandCommand.ViewModel)context.DataContext;

            bool canExecute = viewModel.Items.Count < 100;

            return(canExecute);
        }