private void scoreButton_Click(object sender, RoutedEventArgs e) { ScoreWindow scoreWindow = new ScoreWindow(); scoreWindow.Show(); ScoreContext scoreContext = new ScoreContext(); }
public ScoreWindow() { InitializeComponent(); var scoreContext = new ScoreContext(); var _scores = new ObservableCollection <Score>(scoreContext.Set <Score>().Take(10).ToList()); scores.ItemsSource = _scores; }
private void updateScoreboard() { //Update score first. this.scoreTextBlock.Text = score.ToString(); //Update best score next. if (score > bestScore) { bestScore = score; } this.bestScoreTextBlock.Text = bestScore.ToString(); ScoreContext scoreContext = new ScoreContext(); Score scoreV = new Score(); scoreV.ScoreValue = bestScore; scoreContext.Scores.Add(scoreV); scoreContext.SaveChanges(); }