Untitled
public
Dec 26, 2024
Never
51
1 public partial class MainWindow : Window 2 { 3 4 public GameState gamestate = new GameState { Money = 200, Days = 1 }; 5 6 7 public MainWindow() 8 { 9 WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; 10 MenuWindow menu = new MenuWindow(gamestate); 11 DataContext = gamestate; 12 menu.Show(); 13 InitializeComponent(); 14 } 15 16 17 private void Button_Click(object sender, RoutedEventArgs e) 18 { 19 //This does nothing 20 //gamestate.ChangeMoney(gamestate.Money, 50); 21 //or 22 //gamestate.Money =+ 50 23 //DataContext = gamestate; 24 25 //This changes the label 26 GameState gamestate = new GameState(); 27 DataContext = gamestate; 28 }