-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBaseCollectionViewModel.cs
executable file
·61 lines (53 loc) · 1.68 KB
/
BaseCollectionViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace Microsoft.MobCAT.MVVM
{
public abstract class BaseCollectionViewModel<T> : BaseViewModel where T : BaseNotifyPropertyChanged
{
ObservableCollection<T> _items;
/// <summary>
/// Gets or sets the items.
/// </summary>
/// <value>Items.</value>
public ObservableCollection<T> Items
{
get => _items;
set => RaiseAndUpdate(ref _items, value);
}
T selectedItem;
/// <summary>
/// Gets or sets the selected item.
/// </summary>
/// <value>Selected Item.</value>
public T SelectedItem
{
get => selectedItem;
set
{
RaiseAndUpdate(ref selectedItem, value);
ItemSelected?.Invoke();
}
}
/// <summary>
/// Gets or sets the action that is called when an item is selected.
/// </summary>
/// <value>The item selected action.</value>
public Action ItemSelected { get; set; }
/// <summary>
/// Gets or sets the action to be called when a reload is requested.
/// </summary>
/// <value>Reload action.</value>
public Action ReloadAction { get; set; }
/// <summary>
/// Gets or sets the action to be called when an action fails.
/// </summary>
/// <value>Failed action.</value>
public Action FailedAction { get; set; }
/// <summary>
/// Loads the items.
/// </summary>
/// <returns>Task.</returns>
public abstract Task LoadItems();
}
}