mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-22 15:00:38 -04:00
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace WowUp.WPF.ViewModels
|
|
{
|
|
public class BaseViewModel : INotifyPropertyChanged
|
|
{
|
|
bool isBusy = false;
|
|
public bool IsBusy
|
|
{
|
|
get { return isBusy; }
|
|
set { SetProperty(ref isBusy, value); }
|
|
}
|
|
|
|
protected bool SetProperty<T>(
|
|
ref T backingStore,
|
|
T value,
|
|
[CallerMemberName] string propertyName = "",
|
|
Action onChanged = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(backingStore, value))
|
|
return false;
|
|
|
|
backingStore = value;
|
|
onChanged?.Invoke();
|
|
OnPropertyChanged(propertyName);
|
|
return true;
|
|
}
|
|
|
|
#region INotifyPropertyChanged
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
var changed = PropertyChanged;
|
|
if (changed == null)
|
|
return;
|
|
|
|
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|