Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LoadingListView.cs
1using System.Collections;
2using System.Windows.Input;
3
5{
9 public class LoadingListView : ListView
10 {
14 public static readonly BindableProperty LoadMoreCommandProperty =
15 BindableProperty.Create(nameof(LoadMoreCommand), typeof(ICommand), typeof(LoadingListView), default(ICommand));
16
20 public ICommand LoadMoreCommand
21 {
22 get => (ICommand)this.GetValue(LoadMoreCommandProperty);
23 set => this.SetValue(LoadMoreCommandProperty, value);
24 }
25
29 public static readonly BindableProperty ItemSelectedCommandProperty =
30 BindableProperty.Create(nameof(ItemSelectedCommand), typeof(ICommand), typeof(LoadingListView), default(ICommand));
31
35 public ICommand ItemSelectedCommand
36 {
37 get => (ICommand)this.GetValue(ItemSelectedCommandProperty);
38 set => this.SetValue(ItemSelectedCommandProperty, value);
39 }
40
45 {
46 this.ItemAppearing += this.LoadingListView_ItemAppearing;
47 this.ItemSelected += this.LoadingListView_ItemSelected;
48 }
49
50 private void LoadingListView_ItemAppearing(object? Sender, ItemVisibilityEventArgs e)
51 {
52 if (this.ItemsSource is IList List && e.Item == List[List.Count - 1])
53 {
54 if (this.LoadMoreCommand?.CanExecute(null) ?? false)
55 this.LoadMoreCommand.Execute(null);
56 }
57 }
58
59 private void LoadingListView_ItemSelected(object? Sender, SelectedItemChangedEventArgs e)
60 {
61 if (this.ItemSelectedCommand?.CanExecute(null) ?? false)
62 this.ItemSelectedCommand.Execute(this.SelectedItem);
63 }
64
65 }
66}
ListView that can load new items when the last items is being displayed
static readonly BindableProperty ItemSelectedCommandProperty
static readonly BindableProperty LoadMoreCommandProperty
ICommand LoadMoreCommand
Command executed when last item is appearing and new data should be loaded.
LoadingListView()
ListView that can load new items when the last items is being displayed
ICommand ItemSelectedCommand
Command executed when last item is appearing and new data should be loaded.