Create RadioButton in WPF using VB.NET

In this article you will learn about the RadioButton creation in WPF.
  • 2010
 

RadioButton

RadioButton is a function and this function have two parts one is selectable box, or circle and other is associated text. The selection of any one-radio button de-selects any previous choice. The action of a radio button selection is not processed until a push button is selected.

In WPF RadioButton derived from the ToggleButton and uses the same IsChecked property and the same Checked, Unchecked, and Indetermination events. There is property which is very important or we can say necessary for the RadioButton, the name of this single property is GroupName property, this property allows the user to control how radio button are placed into groups.

The GroupName property allows you to override this behavior. You can use it to create more than one group in the same container or to create a single group that spans multiple containers. Either way, the trick is simple-just give all the radio buttons that belong together the same group name.

Example of the RadioButton

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">
    <StackPanel>
        <RadioButton GroupName="Class 1">1</RadioButton>
        <RadioButton GroupName="Class 2">2</RadioButton>
        <RadioButton GroupName="Class 3">3</RadioButton>
        <RadioButton GroupName="Class 4">4</RadioButton>
    </StackPanel>
</
Page>

Output Window

 radio.gif

Conclusion

Hope this article helps you to understand the RadioButton in WPF.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.