Skip to content

Instantly share code, notes, and snippets.

@BryanOroxon
Created December 30, 2019 16:47
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 BryanOroxon/2883ab2636cd2e0964f6111d0e6b23e0 to your computer and use it in GitHub Desktop.
Save BryanOroxon/2883ab2636cd2e0964f6111d0e6b23e0 to your computer and use it in GitHub Desktop.
BaseViewModel.cs
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
using GifInMotion.Services;
namespace GifInMotion.ViewModels
{
public class BaseViewModel : INotifyPropertyChanged
{
public IDataService DataService { get; }
public BaseViewModel()
{
DataService = DependencyService.Get<IDataService>();
}
bool isBusy;
string title;
public string Title
{
get => title;
set
{
if (title == value)
return;
title = value;
OnPropertyChanged();
}
}
public bool IsBusy
{
get => isBusy;
set
{
if (isBusy == value)
return;
isBusy = value;
OnPropertyChanged();
OnPropertyChanged(nameof(IsNotBusy));
}
}
public bool IsNotBusy => !IsBusy;
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName]string name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment