Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF radio button checking

Now im coding my first gui program and i have a problem(I know its very simple,but i cant find an answer for it).I have 2 radio buttons,separeted from eachother,and i cant check if radio button is checked ,here`s my code:

 <RadioButton Content="Metinės"
                 Checked="RadioButton_Checked_1"
                 HorizontalAlignment="Left"
                 Margin="393,124,0,0"
                 Height="21"
                 Width="101"
                 FontSize="14"
                 ClickMode="Press"
                 VerticalAlignment="Top"
                 FontFamily="Segoe WP Semibold"/>

And c#

  if (RadioButton_Checked == true)
            {
                //program code
            }
like image 958
pauliustack Avatar asked Oct 20 '13 13:10

pauliustack


Video Answer


1 Answers

Give x:Name or Name to your RadioButton like

<RadioButton x:Name="MyRadioButton" Content="Metinės"/>

and then in code behind you can check

if(MyRadioButton.IsChecked == true)
{
}
like image 134
Nitin Avatar answered Sep 21 '22 23:09

Nitin