RadioButton Example

Radio Buttons have an Initialize constructor that will allow you to define whether it is checked by default, whether it is "tri-state", and what its group name is. A group name is used to group more than one radio button together, so that if you check one, it will uncheck the previously checked one.

Here is an example of two radio buttons (grouped together):

RadioButton rdbi1 = new RadioButton();
rdbi1.Initialize(ContainerType.HorizontalPanel, false, false, "metalsGroup");

.AddText<RadioButton>(0, 0, "Iron")
.EndComposite<RadioButton, RadioButtonArgs>(null);

RadioButton rdbi2 = new RadioButton();
rdbi2.Initialize(ContainerType.HorizontalPanel, true, false, "metalsGroup");

.AddText<RadioButton>(0, 0, "Steel")
.EndComposite<RadioButton, RadioButtonArgs>(null);

//Add the radio buttons to a Stack Panel
.Set<CheckBox, StackPanel>(0, 1, "Margin", new Thickness(5))
.Set<RadioButton, StackPanel>(0, 2, "Margin", new Thickness(5, 3, 5, 1))
.Set<RadioButton, StackPanel>(0, 3, "Margin", new Thickness(5, 0, 5, 3))

.AddExisting<RadioButton, StackPanel>(0, 2, rdbi1)
.EndComposite<StackPanel, StackPanelArgs>(null);

.AddExisting<RadioButton, StackPanel>(0, 3, rdbi2)
.EndComposite<StackPanel, StackPanelArgs>(null);

Last edited Mar 28, 2014 at 6:35 AM by stagathome0069, version 3


No comments yet.