TemplateVM.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using YJMPD_UWP.Helpers;
  2. using System;
  3. using System.ComponentModel;
  4. using Windows.UI.Core;
  5. namespace YJMPD_UWP.ViewModels
  6. {
  7. public class TemplateVM : INotifyPropertyChanged
  8. {
  9. protected CoreDispatcher dispatcher;
  10. public TemplateVM(string title)
  11. {
  12. dispatcher = App.Dispatcher;
  13. Settings.OnLanguageUpdate += Settings_OnLanguageUpdate;
  14. if (App.MainPage != null)
  15. App.MainPage.Title = title;
  16. }
  17. private void Settings_OnLanguageUpdate(EventArgs e)
  18. {
  19. dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
  20. {
  21. UpdatePropertiesToNewLanguage();
  22. });
  23. }
  24. protected virtual void UpdatePropertiesToNewLanguage()
  25. {
  26. //to implement in underlying class
  27. }
  28. public event PropertyChangedEventHandler PropertyChanged;
  29. protected void NotifyPropertyChanged(string propertyName)
  30. {
  31. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  32. }
  33. }
  34. }