Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created November 25, 2019 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/6fd01b0913e19dcea68ed86351522ced to your computer and use it in GitHub Desktop.
Save icebeam7/6fd01b0913e19dcea68ed86351522ced to your computer and use it in GitHub Desktop.
DemoDS: BaseViewModel.cs
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace DemoDS.ViewModels
{
public class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (object.Equals(storage, value)) return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
private bool _isBusy = false;
public bool IsBusy
{
get => _isBusy;
set => SetProperty(ref _isBusy, value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment