Last active
January 23, 2019 00:46
-
-
Save 15mgm15/2cb919ac2f663b3abef0400c96c7d417 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
using Xamarin.Forms; | |
namespace XXXXXXXX | |
{ | |
public class BaseViewModel : INotifyPropertyChanged | |
{ | |
public INavigation Navigation { get; set; } | |
public BaseViewModel(INavigation navigation) | |
{ | |
Navigation = navigation; | |
} | |
protected bool SetValue<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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment