-
-
Save BryanOroxon/2883ab2636cd2e0964f6111d0e6b23e0 to your computer and use it in GitHub Desktop.
BaseViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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