using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Xamarin.Forms.Controls { public class HBaseViewModel : INotifyPropertyChanged { public HBaseViewModel() { } private string title = string.Empty; public const string TitlePropertyName = "Title"; /// /// Gets or sets the "Title" property /// /// The title. public string Title { get { return title; } set { SetProperty(ref title, value); } } private string subtitle = string.Empty; /// /// Gets or sets the "Subtitle" property /// public const string SubtitlePropertyName = "Subtitle"; public string Subtitle { get { return subtitle; } set { SetProperty(ref subtitle, value); } } private string icon = null; /// /// Gets or sets the "Icon" of the viewmodel /// public const string IconPropertyName = "Icon"; public string Icon { get { return icon; } set { SetProperty(ref icon, value); } } bool isBusy; /// /// Gets or sets a value indicating whether this instance is busy. /// /// true if this instance is busy; otherwise, false. public bool IsBusy { get { return isBusy; } set { if (SetProperty(ref isBusy, value)) IsNotBusy = !isBusy; } } bool isNotBusy = true; /// /// Gets or sets a value indicating whether this instance is not busy. /// /// true if this instance is not busy; otherwise, false. public bool IsNotBusy { get { return isNotBusy; } private set { SetProperty(ref isNotBusy, value); } } private bool canLoadMore = true; /// /// Gets or sets if we can load more. /// public const string CanLoadMorePropertyName = "CanLoadMore"; public bool CanLoadMore { get { return canLoadMore; } set { SetProperty(ref canLoadMore, value); } } protected bool SetProperty( ref T backingStore, T value, [CallerMemberName]string propertyName = "", Action onChanged = null) { if (EqualityComparer.Default.Equals(backingStore, value)) return false; backingStore = value; if (onChanged != null) onChanged(); OnPropertyChanged(propertyName); return true; } #region INotifyPropertyChanged implementation public event PropertyChangedEventHandler PropertyChanged; #endregion public void OnPropertyChanged([CallerMemberName] string propertyName = "") { var changed = PropertyChanged; if (changed == null) return; changed(this, new PropertyChangedEventArgs(propertyName)); } } }