Last active
January 27, 2016 19:25
-
-
Save RedTahr/92abca6781cde7813a26 to your computer and use it in GitHub Desktop.
Xamarin.Forms BaseViewModel
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
namespace ... { | |
public abstract class BaseViewModel : BindableObject { // yeah its overkill, can't recall why my colleague did it this way | |
private string title = string.Empty; | |
public string Title { | |
get { return title; } | |
set { | |
if(title != value) { | |
title = value; | |
RaisePropertyChanged(); | |
} | |
} | |
} | |
//private string icon = null; | |
//public string Icon { | |
// get { return icon; } | |
// set { | |
// if (icon != value) { | |
// icon = value; | |
// RaisePropertyChanged(); | |
// } | |
// } | |
//} | |
private bool isBusy = false; | |
public const string IsBusyPropertyName = "IsBusy"; | |
public bool IsBusy { | |
get { return isBusy; } | |
set { | |
if (isBusy != value) { | |
isBusy = value; | |
RaisePropertyChanged(); | |
} | |
} | |
} | |
// an idea from XLabs | |
public virtual void OnAppearing() { } | |
public virtual void OnDisappearing() { } | |
// from a C# book, o'Reaillys in a nutshell I think it was. | |
internal void RaisePropertyChanged([CallerMemberName] string propertyName = null) { | |
OnPropertyChanged(propertyName); | |
} | |
// from Chris Riesgo's CarouselView Layout | |
//protected void SetObservableProperty<T>( | |
// ref T field, | |
// T value, | |
// [CallerMemberName] string propertyName = "") { | |
// if (EqualityComparer<T>.Default.Equals(field, value)) return; | |
// field = value; | |
// OnPropertyChanged(propertyName); | |
//} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment