public DistanceTextBlock() { InitializeComponent(); DataContextChanged += (sender, args) => { UpdateDistance(); }; _mainVm = ServiceLocator.Current.GetInstance<MainViewModel>(); _settings = ServiceLocator.Current.GetInstance<SettingsService>(); _localization = ServiceLocator.Current.GetInstance<LocalizationService>(); _mainVm.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(_mainVm.UserLocation)) { UpdateDistance(); } }; Messenger.Default.Register(this, (SettingChangedMessage msg) => { if (msg.IsSetting(nameof(_settings.DistanceUnit)) || msg.IsSetting(nameof(_settings.CurrentLocale))) { UpdateDistance(); } }); }
public SettingsViewModel(SettingsService settings, LocalizationService localization) { _settings = settings; _localization = localization; _distanceUnit = settings.DistanceUnit; _displayedLocale = settings.CurrentLocale; _locale = settings.CurrentLocale; _showExperimentalCities = settings.ShowExperimentalCities; RaisePropertyChanged(() => Locale); RaisePropertyChanged(() => LocaleDefaultIndex); RaisePropertyChanged(() => LanguageChanged); RaisePropertyChanged(() => ChangeLanguageString); }