语言

RadioButton.GroupName 属性

定义

获取或设置指定哪些 RadioButton 控件互斥的名称。

public:
 property System::String ^ GroupName { System::String ^ get(); void set(System::String ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
public string GroupName { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
member this.GroupName : string with get, set
Public Property GroupName As String

属性值

指定哪些 RadioButton 控件互斥的名称。 默认值为空字符串。

特性

示例

下面的代码示例创建两个单独的 RadioButton 组: colorgrp 和 numgrp。 用户可以在每个组中选择一个 RadioButton 。

<StackPanel>
    <RadioButton GroupName="colorgrp">Red</RadioButton>
    <RadioButton GroupName="colorgrp">Blue</RadioButton>
    <RadioButton GroupName="numgrp">1</RadioButton>
    <RadioButton GroupName="numgrp">2</RadioButton>
</StackPanel>

注解

当两个或多个 RadioButton 控件具有相同时 GroupName,用户一次只能选择一个 RadioButton 控件。

Dependency 属性信息

项目 价值
标识符字段 GroupNameProperty
元数据属性设置为 true None

适用于