private void Handler(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(SelectedObject.Tyres): SelectedTyres = Tyres.ElementAtOrDefault(SelectedObject.Tyres); break; } }
public ViewModel(CarObject car, [NotNull] CarSetupObject acObject) : base(acObject) { Car = car; var main = Car.AcdData?.GetIniFile("car.ini"); SelectedObject.FuelMaximum = main?["FUEL"].GetInt("MAX_FUEL", 0) ?? 0; var tyres = Car.AcdData?.GetIniFile("tyres.ini"); Tyres = tyres?.GetSections("FRONT", -1).Select((x, i) => new SettingEntry(i, x.GetPossiblyEmpty("NAME"))).ToArray(); SelectedTyres = Tyres?.ElementAtOrDefault(SelectedObject.Tyres); WeakEventManager <INotifyPropertyChanged, PropertyChangedEventArgs> .AddHandler(acObject, nameof(PropertyChanged), Handler); }