PowerApps 中的单选控件Radio control in PowerApps

显示所有选项的列表,但用户只能一次选择一个选项。A list that shows all options but the user can select only one at a time.

说明Description

用户有几十年使用经验的“单选”控件最好只与几个互斥选项一同使用。A Radio control, with which users have decades of experience, is best used with only a few options that are mutually exclusive.

关键属性Key properties

Default - 用户更改控件前的初始值。Default – The initial value of a control before it is changed by the user.

Items - 控件中显示的数据源,如库、列表或图表。Items – The source of data that appears in a control such as a gallery, a list, or a chart.

Items:在库、列表或图表等控件中显示的数据的源。Items The source of data that appears in a control such as a gallery, a list, or a chart.

在添加库、列表或图表时,属性列表会默认显示“Items”,以便你轻松指定新控件应显示的数据。When you add a gallery, a list, or a chart, the property list shows Items by default so that you can easily specify the data that the new control should show. 例如,可以将库的“Items”属性设置为 Salesforce 中的“Account”表,在 Excel 中创建并上载到云的名为“Inventory”的表,或者名为“ConferenceSpeakers”的 SharePoint 列表。For example, you might set the Items property of a gallery to the Account table in Salesforce, a table named Inventory that you created in Excel and uploaded to the cloud, or a SharePoint list named ConferenceSpeakers.

Value – 输入控件的值。Value – The value of an input control.

所有属性All properties

Align – 文本相对于其控件的水平居中的位置。Align – The location of text in relation to the horizontal center of its control.

BorderColor – 控件边框的颜色。BorderColor – The color of a control's border.

BorderStyle – 控件边框是实线虚线点线还是BorderStyle – Whether a control's border is Solid, Dashed, Dotted, or None.

BorderThickness – 控件边框的粗细。BorderThickness – The thickness of a control's border.

FocusedBorderThickness – 控件具有键盘焦点时的边框粗细。FocusedBorderThickness – The thickness of the control's border when it has keyboard focus.

Color – 控件中文本的颜色。Color – The color of text in a control.

DisplayMode – 此控件是允许用户输入 (Edit)、仅显示数据 (View),还是已禁用 (Disabled)。DisplayMode – Whether the control allows user input (Edit), only displays data (View), or is disabled (Disabled).

DisabledBorderColor – 控件的 DisplayMode 属性设置为 Disabled 时,该控件边框的颜色。DisabledBorderColor – The color of a control's border if the control's DisplayMode property is set to Disabled.

DisabledColor – 控件的 DisplayMode 属性设置为 Disabled 时,该控件中的文本颜色。DisabledColor – The color of text in a control if its DisplayMode property is set to Disabled.

DisabledFill – 控件的 DisplayMode 属性设置为 Disabled 时,该控件的背景颜色。DisabledFill – The background color of a control if its DisplayMode property is set to Disabled.

Fill – 控件的背景颜色。Fill – The background color of a control.

Font – 文本中所显示的字体系列的名称。Font – The name of the family of fonts in which text appears.

FontWeight – 控件中文本的粗细:粗体半粗体正常细体FontWeight – The weight of the text in a control: Bold, Semibold, Normal, or Lighter.

Height – 控件上边缘和下边缘之间的距离。Height – The distance between a control's top and bottom edges.

HoverColor – 用户将鼠标指针停留在控件上时,该控件中的文本颜色。HoverColor – The color of the text in a control when the user keeps the mouse pointer on it.

HoverFill – 用户将鼠标指针停留在控件上时,该控件的背景颜色。HoverFill – The background color of a control when the user keeps the mouse pointer on it.

Italic – 控件中的文本是否为斜体。Italic – Whether the text in a control is italic.

LineHeight - 文本行之间或列表项之间的距离。LineHeight – The distance between, for example, lines of text or items in a list.

OnChange - 用户更改控件的值(例如,通过调整滑块)时应用的响应方式。OnChange – How the app responds when the user changes the value of a control (for example, by adjusting a slider).

OnSelect – 用户点击或单击某个控件时应用响应的方式。OnSelect – How the app responds when the user taps or clicks a control.

PaddingBottom – 控件中的文本与该控件下边缘之间的距离。PaddingBottom – The distance between text in a control and the bottom edge of that control.

PaddingLeft - 控件中的文本与该控件的左边缘之间的距离。PaddingLeft – The distance between text in a control and the left edge of that control.

PaddingRight - 控件中的文本与该控件的右边缘之间的距离。PaddingRight – The distance between text in a control and the right edge of that control.

PaddingTop - 控件中的文本与此控件的上边缘之间的距离。PaddingTop – The distance between text in a control and the top edge of that control.

PressedColor – 用户在点击或单击控件时,该控件中的文本的颜色。PressedColor – The color of text in a control when the user taps or clicks that control.

PressedFill – 用户在点击或单击控件时,该控件的背景色。PressedFill – The background color of a control when the user taps or clicks that control.

RadioBackgroundFill - 单选按钮控件中的圆圈背景色。RadioBackgroundFill – The background color of the circles in a radio-button control.

RadioBorderColor - 单选按钮控件中每个选项的圆圈颜色。RadioBorderColor – The color of the circle for each option in a radio-button control.

RadioSelectionFill - 单选按钮控件中选定选项的圆圈内显示的颜色。RadioSelectionFill – The color that appears inside the circle of the selected option in a radio-button control.

RadioSize - 单选按钮控件中的圆圈直径。RadioSize – The diameter of the circles in a radio-button control.

Reset - 是否还原控件的默认值。Reset – Whether a control reverts to its default value.

Size – 控件上显示的文本的字号。Size – The font size of the text that appears on a control.

Strikethrough – 通过文本显示的线是否在控件上显示。Strikethrough – Whether a line appears through the text that appears on a control.

TabIndex - 设置为非零值时,在运行时自定义控件的选项卡顺序。TabIndex – Customizes the tab order of controls at runtime when set to a non-zero value.

Tooltip - 用户将鼠标悬停在控件上时显示的解释性文本。Tooltip – Explanatory text that appears when the user hovers over a control.

Underline – 在文本下方显示的线是否在控件上显示。Underline – Whether a line appears under the text that appears on a control.

Visible – 控件显示还是隐藏。Visible – Whether a control appears or is hidden.

Width – 控件左边缘和右边缘之间的距离。Width – The distance between a control's left and right edges.

X - 控件左边缘与其父容器(如果没有父容器,则为屏幕)左边缘之间的距离。X – The distance between the left edge of a control and the left edge of its parent container (screen if no parent container).

Y - 控件上边缘与其父容器(如果没有父容器,则为屏幕)上边缘之间的距离。Y – The distance between the top edge of a control and the top edge of the parent container (screen if no parent container).

Distinct( DataSource, ColumnName )Distinct( DataSource, ColumnName )

示例Example

  1. 添加“单选”控件并命名为“Pricing”,然后将其“Items”属性设为以下公式:Add a Radio control, name it Pricing, and set its Items property to this formula:
    ["Standard", "Premium"]["Standard", "Premium"]

    不知道如何添加、命名和配置控件Don't know how to add, name, and configure a control?

  2. 添加一个“标签”控件,将它移到“单选按钮”控件下方,然后将“标签”控件的“Text”属性设置为以下公式:Add a Label control, move it below the Radio control, and set the Text property of the Label control to this formula:
    If("Premium" in Pricing.Selected.Value, "$200 per day", "$150 per day")If("Premium" in Pricing.Selected.Value, "$200 per day", "$150 per day")

    想要详细了解 If 函数或其他函数吗?Want more information about the If function or other functions?

  3. 按 F5 键,然后选中“单选”控件中的任一选项。Press F5, and then choose either option in the Radio control.

    此时,“标签”控件会显示所选的相应文本。The Label control shows the appropriate text for your choice.

  4. (可选)选中“单选”控件中的另一选项,以确认相应文本是否会显示。(optional) In the Radio control, choose the other option to confirm that the appropriate text appears.
  5. 若要返回到默认工作区,请按 Esc 键。To return to the default workspace, press Esc.