Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created December 16, 2018 13:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save icebeam7/5d9df1bc819b6a96100563099e410e90 to your computer and use it in GitHub Desktop.
VideoGameMusicApp: BaseViewModel.cs
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace VideoGameMusicApp.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 _isLoading = false;
public bool IsLoading
{
get => _isLoading;
set => SetProperty(ref _isLoading, value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment