-
Notifications
You must be signed in to change notification settings - Fork 0
/
SubScreenViewModel.cs
121 lines (104 loc) · 3 KB
/
SubScreenViewModel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
namespace ArcOrganization.Infrastructure.ViewModels
{
using System.Threading.Tasks;
using Caliburn.Micro;
/// <summary>
/// The base ViewModel that derives from the <see cref="Screen"/>.
/// </summary>
/// <remarks>
/// Use this base class to provide Screen behavior for the ViewModel</remarks>
public abstract class SubScreenViewModel : Screen, IRefreshable
{
private bool _isBusy;
private string _busyText;
private bool _isLoaded;
/// <summary>
/// Gets or sets a value indicating whether the ViewModel is busy like initializing or searching.
/// </summary>
public bool IsBusy
{
get
{
return _isBusy;
}
set
{
if (value.Equals(_isBusy))
{
return;
}
_isBusy = value;
NotifyOfPropertyChange(() => IsBusy);
}
}
/// <summary>
/// Gets or sets the text for the busy indication
/// </summary>
public string BusyText
{
get
{
return _busyText;
}
set
{
if (value == _busyText)
{
return;
}
_busyText = value;
NotifyOfPropertyChange(() => BusyText);
}
}
/// <summary>
/// Gets or sets a value indicating whether the ViewModel has loaded its initial content.
/// </summary>
public bool IsLoaded
{
get
{
return _isLoaded;
}
set
{
if (value.Equals(_isLoaded))
{
return;
}
_isLoaded = value;
NotifyOfPropertyChange(() => IsLoaded);
}
}
/// <summary>
/// Gets or sets a value indicating whether previous page is removed the source page from the back stack.
/// </summary>
/// <remarks>
/// Usage :
/// <code>
/// this.navigationService.UriFor{ViewModelWhereToNavigate}().WithParam(p => p.RemoveFromBackstackNavigation, true).Navigate();
/// </code>
/// </remarks>
public bool RemoveFromBackstackNavigation { get; set; }
protected virtual void SetBusy(string busyText = "Loading...")
{
BusyText = busyText;
IsBusy = true;
}
protected virtual void SetNotBusy()
{
IsBusy = false;
BusyText = string.Empty;
}
/// <summary>
/// Override to load initial content.
/// </summary>
/// <returns></returns>
public virtual async Task LoadContentAsync()
{
}
public virtual async Task RefreshContentAsync()
{
await LoadContentAsync();
}
}
}