Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace SimpleLogin.ViewModels
  10. {
  11. public class ViewModelBase : INotifyPropertyChanged
  12. {
  13. string title = string.Empty;
  14.  
  15. /// <summary>
  16. /// Gets or sets the title.
  17. /// </summary>
  18. /// <value>The title.</value>
  19. public string Title
  20. {
  21. get { return title; }
  22. set { SetProperty(ref title, value); }
  23. }
  24.  
  25. string icon = string.Empty;
  26.  
  27. /// <summary>
  28. /// Gets or sets the icon.
  29. /// </summary>
  30. /// <value>The icon.</value>
  31. public string Icon
  32. {
  33. get { return icon; }
  34. set { SetProperty(ref icon, value); }
  35. }
  36.  
  37. bool isBusy;
  38.  
  39. /// <summary>
  40. /// Gets or sets a value indicating whether this instance is busy.
  41. /// </summary>
  42. /// <value><c>true</c> if this instance is busy; otherwise, <c>false</c>.</value>
  43. public bool IsBusy
  44. {
  45. get { return isBusy; }
  46. set
  47. {
  48. SetProperty(ref isBusy, value);
  49. }
  50. }
  51.  
  52.  
  53. /// <summary>
  54. /// Sets the property.
  55. /// </summary>
  56. /// <returns><c>true</c>, if property was set, <c>false</c> otherwise.</returns>
  57. /// <param name="backingStore">Backing store.</param>
  58. /// <param name="value">Value.</param>
  59. /// <param name="propertyName">Property name.</param>
  60. /// <param name="onChanged">On changed.</param>
  61. /// <typeparam name="T">The 1st type parameter.</typeparam>
  62. protected bool SetProperty<T>(
  63. ref T backingStore, T value,
  64. [CallerMemberName]string propertyName = "",
  65. Action onChanged = null)
  66. {
  67. if (EqualityComparer<T>.Default.Equals(backingStore, value))
  68. return false;
  69.  
  70. backingStore = value;
  71. onChanged?.Invoke();
  72. OnPropertyChanged(propertyName);
  73. return true;
  74. }
  75.  
  76. /// <summary>
  77. /// Occurs when property changed.
  78. /// </summary>
  79. public event PropertyChangedEventHandler PropertyChanged;
  80. /// <summary>
  81. /// Raises the property changed event.
  82. /// </summary>
  83. /// <param name="propertyName">Property name.</param>
  84. protected void OnPropertyChanged([CallerMemberName]string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  85.  
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement