✅ [solved] Learning Desktop App WPF Application
Ok. So I've built the front-end part of the welcome screen. I'm learning how to do this so be gentle please lol but it's my math game. I'm taking it from a console based app to an actual desktop app. So my question is, I have 2 sets of radio button selections, a combobox, and 2 buttons.
In my
StartGame_Click
method, I want to be able to capture the input from the radio buttons so that I can pass the needed information to the required functions. How do I get the radio button selections?4 Replies
I have these radio buttons inside of a GroupBox with a Name. I have the corresponding code
All I'm trying to do is get the
MessageBox
to show the text of the selected radio button. I also have another radio button group named gameSelection
and i have a ComboBox
that I need to get the text of the selected radio button and the selected text of the selected index of the combo box and display them in the MessageBox, but when I click the start game button, the message box is completely empty. What am I doing wrong? My code here is based off this stack overflow which I understand is from 2015, but it was the best I thought I found
https://stackoverflow.com/questions/29586150/get-input-from-radio-buttons-wpf-c-sharpStack Overflow
Get input from radio buttons wpf C#
Voila XML code
<GroupBox x:Name="radioButtons">
<StackPanel Orientation="Horizontal">
<RadioButton Content="Teacher" HorizontalAlignment="Left" Margin="168,171,0,0"
I got it. nevermind ty
Wpf has a pretty good data binding system, frequently people take advantage of the binding system and use a concept called mvvm, I encourage you to google wpf mvvm and learn about that too.
xaml code: https://pastebin.com/5j6dUAVD
C# code: https://pastebin.com/ahcD3b8W
i'm trying to figure out how to get the value of which radio button is selected on button click. In the first group box named
difficultyRadio
I need to get access to which difficulty the user selected. In the second GroupBox
named gameSelection
, I need to get access to which game the user selected. Finally, I need to get which item the user selected (if not index 0 or "Select One") so that the program knows how many questions the user wants to answer.Displaying them in the message box is for confirmation for the user. I want the message box to basically pop up and say the difficulty, game, and number of questions the user entered with a confirm button and a back button to go back to the home screen to reselect if the user so chooses.
nevermind on this. I'm going back to the basics and learning stuff over again. THanks