root / GES_PAC / ViewModel / BaseViewModel.cs @ 9601eaf0
Historique | Voir | Annoter | Télécharger (1,04 ko)
1 | 65ad7e66 | Lucas Bihannic | using System.ComponentModel; |
---|---|---|---|
2 | using System.Runtime.CompilerServices; |
||
3 | |||
4 | namespace GES_PAC.ViewModel |
||
5 | { |
||
6 | public class BaseViewModel : INotifyPropertyChanged |
||
7 | { |
||
8 | 1019554c | lbihannic | private bool isBusy = false; |
9 | 18f910c6 | Lucas Bihannic | |
10 | public bool IsBusy |
||
11 | { |
||
12 | get |
||
13 | { |
||
14 | return isBusy; |
||
15 | } |
||
16 | set |
||
17 | { |
||
18 | isBusy = value; |
||
19 | OnPropertyChanged(nameof(IsBusy)); |
||
20 | } |
||
21 | } |
||
22 | |||
23 | 65ad7e66 | Lucas Bihannic | public event PropertyChangedEventHandler PropertyChanged; |
24 | protected void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||
25 | { |
||
26 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
27 | } |
||
28 | |||
29 | protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null) |
||
30 | { |
||
31 | if (EqualityComparer<T>.Default.Equals(field, value)) return false; |
||
32 | |||
33 | field = value; |
||
34 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
35 | return true; |
||
36 | } |
||
37 | } |
||
38 | } |