#857 – Manually Grouping RadioButtons
July 5, 2013 1 Comment
RadioButtons are normally automatically grouped, based on panel control in which they are located in. All RadioButtons within a particular panel are considered part of the same group–which means that exactly one RadioButton at a time can be selected.
You can, however, manually control which RadioButtons are considered to be part of a group, regardless of the parent panel in which they are located. You specify membership in a group using the GroupName property. GroupName can be set to any string value. RadioButton instances having the same value for GroupName are considered part of the same group.
<Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <RadioButton Content="Extrovert" GroupName="EI"/> <RadioButton Grid.Row="1" Content="Introvert" GroupName="EI"/> <RadioButton Grid.Column="1" Content="Sensing" GroupName="SN"/> <RadioButton Grid.Row="1" Grid.Column="1" Content="Intuition" GroupName="SN"/> <RadioButton Grid.Column="2" Content="Thinking" GroupName="TF"/> <RadioButton Grid.Row="1" Grid.Column="2" Content="Feeling" GroupName="TF"/> </Grid>