Kamis, 12 September 2013

How to Use Radio Button in: WPF

This is another control derives from the Toggle Button. It has a different in-built feature that the toggle button doesn’t have. That feature is mutual exclusion, it means if 2 or more radio buttons are grouped together on a form/user control, then only one can be checked at a time. User cant checked multiple radio buttons.

When we check a radio button, all others got unchecked in a single group. Following code will show three radio buttons having individual state:
<RadioButton Margin="5" Name="radioButton1" IsChecked="True" Content="Checked"></RadioButton>
<RadioButton Margin="5" Name="radioButton2" IsChecked="False" Content="UnChecked"></RadioButton>
<RadioButton Margin="5"  Name="radioButton3" IsChecked="{x:Null}" Content="InDeterminate"></RadioButton>

Run the above code and it will display three radio buttons displayed in the following image:

How to use Radio Button in WPF

As the toggle button, it has also IsThreeState property for enable its all three states to be used. To group more than radio buttons we have to specify the same GroupName for all the radio buttons.

To show some text with a radio button, we have to use content property as used in above code.

Tidak ada komentar:

Posting Komentar