private void TryCreateGround(object s, RoutedEventArgs e) { CoffeeViewModel x = (CoffeeViewModel)this.DataContext; x.GroundList.Add(new GroundModel() { Parent = x }); x.NotifyChange("GroundList"); }
private void TryDeleteGround(object s, RoutedEventArgs e) { CoffeeViewModel x = (CoffeeViewModel)this.DataContext; if (x.GroundList.Count <= 1) { return; } int current_index = x.GroundList.IndexOf(x.CurrentGround); x.GroundList.Remove(x.CurrentGround); x.CurrentGround = x.GroundList[current_index - 1 < 0? 0 : current_index - 1]; }
private void Shutdown(object sender, CancelEventArgs e) { CoffeeViewModel x = (CoffeeViewModel)this.DataContext; Persistence.Save(x.GroundList); }