Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LoadingCollectionView.cs
1using System.Windows.Input;
2
4{
8 public class LoadingCollectionView : CollectionView
9 {
13 public static readonly BindableProperty LoadMoreCommandProperty =
14 BindableProperty.Create(nameof(LoadMoreCommand), typeof(ICommand), typeof(LoadingCollectionView), default(ICommand));
15
19 public ICommand LoadMoreCommand
20 {
21 get => (ICommand)this.GetValue(LoadMoreCommandProperty);
22 set => this.SetValue(LoadMoreCommandProperty, value);
23 }
24
28 public static readonly BindableProperty ItemSelectedCommandProperty =
29 BindableProperty.Create(nameof(ItemSelectedCommand), typeof(ICommand), typeof(LoadingCollectionView), default(ICommand));
30
34 public ICommand ItemSelectedCommand
35 {
36 get => (ICommand)this.GetValue(ItemSelectedCommandProperty);
37 set => this.SetValue(ItemSelectedCommandProperty, value);
38 }
39
44 {
45 this.RemainingItemsThresholdReached += this.LoadingCollectionView_ThresholdReached;
46 this.SelectionChanged += this.LoadingCollectionView_SelectionChanged;
47 }
48
49 private void LoadingCollectionView_ThresholdReached(object? Sender, EventArgs e)
50 {
51 if (this.LoadMoreCommand?.CanExecute(null) ?? false)
52 this.LoadMoreCommand.Execute(null);
53 }
54
55 private void LoadingCollectionView_SelectionChanged(object? Sender, SelectionChangedEventArgs e)
56 {
57 if (this.ItemSelectedCommand?.CanExecute(null) ?? false)
58 this.ItemSelectedCommand.Execute(this.SelectedItem);
59 }
60
61 }
62}
CollectionView that can load new items when the last items is being displayed
LoadingCollectionView()
ListView that can load new items when the last items is being displayed
static readonly BindableProperty ItemSelectedCommandProperty
static readonly BindableProperty LoadMoreCommandProperty
ICommand ItemSelectedCommand
Command executed when last item is appearing and new data should be loaded.
ICommand LoadMoreCommand
Command executed when last item is appearing and new data should be loaded.