Example #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);
            }
        }
Example #2
0
        /// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">
        /// The parameter used by the command.
        /// </param>
        public void Execute(object parameter)
        {
            RadListView         listView = this.LoadDataControl.Owner;
            LoadMoreDataContext context  = new LoadMoreDataContext {
                View = listView, DataContext = listView.DataContext
            };

            listView.CommandService.ExecuteCommand(Commands.CommandId.LoadMoreData, context);
        }
Example #3
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);
        }
Example #4
0
        internal RadSize MeasureContent(RadSize newAvailableSize)
        {
            var size = this.layoutController.MeasureContent(newAvailableSize);

            if (this.ShouldAutoRequestItems(null))
            {
                LoadMoreDataContext context = new LoadMoreDataContext {
                    View = this.View, DataContext = this.View.GetDataContext()
                };
                this.View.CommandService.ExecuteCommand(CommandId.LoadMoreData, context);
            }

            // NOTE: If we decide that we won't zero the length of collapsed rows then this 'TotalLineCount - 1' will be incorrect.
            // this.desiredSize = new RadSize(this.columnLayout.RenderInfo.OffsetFromIndex(this.columnLayout.TotalLineCount - 1), this.rowLayout.RenderInfo.OffsetFromIndex(this.rowLayout.TotalLineCount - 1));
            // return this.desiredSize;
            return(size);
        }