WPF C# RadioButton

Radiobutton w WPF

// Dodaj grupe RadioButton w pliku xaml
<StackPanel>
  <Label Content="Radio options:"/>
  <RadioButton GroupName="radioGroup"   
      Content="1. Option A"
      Uid="1"
      Checked="RadioButton_Checked"/>
  <RadioButton GroupName="radioGroup"   
      Content="2. Option B"
      Uid="2"
      Checked="RadioButton_Checked"/>
</StackPanel>

// Event handler w pliku xaml.cs
  private void RadioButton_Checked(object sender, RoutedEventArgs e)
  {
      RadioButton btn = sender as RadioButton;
      int id = Int32.Parse(btn.Uid);
  }

Scroll to Top