Search code examples
wpfradio-buttonstackpanel

Accessing Controls inside the content controls in WPF


i have a StackPanel, which contain radio button, i want to access the value of the radio button at runtime, how can i get the radio button value, i am total newbie in WPF, any helps?

<StackPanel Height="73" HorizontalAlignment="Left" Margin="105,78,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="200" >
    <RadioButton Content="Button1" Height="16" Name="radioButton1" Margin="10" />
    <RadioButton Content="Button2" Height="16" Name="radioButton2" Margin="10" />
</StackPanel>

Solution

  • Use radioButton1.IsChecked from the codebehind.