BaseViewModel.cs 893 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. namespace Aitex.UI.Charting.ViewModel
  7. {
  8. public class BaseViewModel : INotifyPropertyChanged
  9. {
  10. public event PropertyChangedEventHandler PropertyChanged;
  11. public void InvokePropertyChanged(string propertyName)
  12. {
  13. PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
  14. PropertyChangedEventHandler changed = PropertyChanged;
  15. if (changed != null)
  16. {
  17. changed(this, eventArgs);
  18. }
  19. }
  20. public void InvokePropertyChanged()
  21. {
  22. Type t = this.GetType();
  23. var ps = t.GetProperties();
  24. foreach (var p in ps)
  25. {
  26. InvokePropertyChanged(p.Name);
  27. }
  28. }
  29. }
  30. }