Reputation: 1132
I am using the .NET Framework 4.5 and observe some strange behavior when I use several RadioButton Controls within a Grid. I would expect to be able to select and deselect each RadioButton individually since I did not use the GroupName property to bind the RadioButtons together. However, I can only select one RadioButton at a time. How can I suppress this behavior? Here is a minimal example:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<RadioButton Grid.Row="0" Grid.Column="0" ></RadioButton>
<RadioButton Grid.Row="1" Grid.Column="0" ></RadioButton>
<RadioButton Grid.Row="2" Grid.Column="0" ></RadioButton>
</Grid>
Upvotes: 0
Views: 99
Reputation: 124
Technically this is expected behavior, but not in the way you may think. GroupName
is a property that expects nothing more than a mere string
and actually defaults to string.Empty
or ""
. There is actually a value for the group it's just an empty string is all, and WPF processes them as being a part of the same grouping. From Microsoft:
The name of the group that the radio button belongs to. The default is an empty string ("").
P.S. Wouldn't checkboxes be more appropriate for this type of situation?
Upvotes: 3