Share via

Initial data load into collectionview

-- -- 957 Reputation points
2023-08-28T03:05:38.8433333+00:00

Hi

I have a collection view as below;

           <dxcv:DXCollectionView
               x:Name="JobsListView"
               IsEnabled="True"
               IsPullToRefreshEnabled="True"
               ItemTemplate="{StaticResource JobCardTemplate}"
               ItemsSource="{Binding JobsList}"
               PullToRefreshCommand="{Binding LoadItemsCommand}"
               TapCommand="{Binding ItemTapped}" />

What is the best way to to do initial data load into the collection view? At present I am calling OnLoadItemsCommand() method inthe constructor of the view model as below. This fills the ObservableCollection JobsList that the collectionview is bound to, however it does not give me an activity indicator on the collection view. I am doing the data upload asynchronously in the OnLoadItemsCommand() method.

        public JobsViewModel()
        {
            LoadItemsCommand = new Command<object>(OnLoadItemsCommand);

            ItemTapped = new Command<Jobs>(OnItemSelected);

            JobsList = new ObservableCollection<Jobs>();

            OnLoadItemsCommand();
        }

How can I do the data load ideally so that it also shows the activity indicator?

Any help would be appreciated. Thanks.

Developer technologies | .NET | .NET Multi-platform App UI
0 comments No comments

Answer accepted by question author

Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,166 Reputation points Microsoft External Staff
2023-08-29T03:05:51.7233333+00:00

Hello,

I checked the PullToRefreshCommand feature of the third-party plugin you're using, which only triggers the update event when you pull down the CollectionView.

For initializing data in a CollectionView, it is recommended that you initialize it in the ViewModel constructor.

Please refer to the official sample CollectionViewDemos for more details.

Best Regards,

Alec Liu.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.