C#C
C#3y ago
22 replies
drewhosick

WPF and variables that I need access to in a Button_Click event

Trying to figure out how to create a random number for a guessing game. Obviously I need to know where to put it so it's accessible to the program and generates a number when the program loads and before I can use the button_Click event on a button. I've attached the code for the random number. I found Window_Loaded but that doesn't seem to be working. I also tried putting it in the Main Window area and without luck. Sorry, still new. Where would it go so it could be accessible to the different events I can setup?
image.png
Was this page helpful?