PowerApps 中的切換控制項Toggle control in PowerApps

使用者可透過移動控制代碼開啟或關閉的控制項。A control that the user can turn on or off by moving its handle.

說明Description

切換是針對最近的 GUI 所設計,但運作方式與核取方塊相同。A toggle is designed for recent GUIs but behaves the same way as a check box.

主要屬性Key properties

Default – 控制項在使用者變更之前的初始值。Default – The initial value of a control before it is changed by the user.

Value – 輸入控制項的值。Value – The value of an input control.

其他屬性Additional properties

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.

DisplayMode – 控制項允許使用者輸入 (編輯)、只顯示資料 (檢視) 或者已停用 (停用)。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.

FalseFill – 切換關閉時的切換填滿色彩。FalseFill – The toggle fill color when the toggle is off.

FalseHoverFill – 切換關閉時的切換暫留填滿色彩。FalseHoverFill – The toggle hover fill color when toggle is off.

FalseText – 切換關閉時顯示的文字。FalseText – The text shown when the toggle is off.

Fill – 控制項的背景色彩。Fill – The background color of a control.

Height – 控制項的頂端和底部邊緣之間的距離。Height – The distance between a control's top and bottom edges.

HoverBorderColor – 使用者將滑鼠指標停留在控制項上時,該控制項所呈現的框線色彩。HoverBorderColor – The color of a control's border when the user keeps the mouse pointer on that control.

OnChange – 使用者變更控制項的值 (例如,調整滑桿) 時,應用程式的回應方式。OnChange – How the app responds when the user changes the value of a control (for example, by adjusting a slider).

OnCheck – 核取方塊或切換的值變更為 true 時,應用程式的回應方式。OnCheck – How an app responds when the value of a checkbox or a toggle changes to true.

OnSelect – 在使用者點選或按一下控制項時,應用程式的回應方式。OnSelect – How the app responds when the user taps or clicks a control.

OnUncheck – 核取方塊或切換的值變更為 false 時,應用程式的回應方式。OnUncheck – How an app responds when the value of a checkbox or a toggle changes to false.

PressedBorderColor – 使用者點選或按一下控制項時,該控制項所呈現的框線色彩。PressedBorderColor – The color of a control's border when the user taps or clicks that control.

RailFill – 當切換控制項的值為 false 時,其矩形背景的色彩,或是滑桿控制項中控點右邊線條的色彩。RailFill – The background color of the rectangle in a toggle control when its value is false or the color of the line to the right of the handle in a slider control.

RailHoverFill – 將滑鼠移至切換控制項或滑桿上時,當其值為 false 時矩形背景的色彩,或是滑桿控制項中控點右邊線條的色彩。RailHoverFill – When you hover on a toggle control or a slider, the background color of the rectangle in a toggle control when its value is false or the color of the line to the right of the handle in a slider control.

Reset – 控制項是否還原為其預設值。Reset – Whether a control reverts to its default value.

ShowLabel – 切換控制項旁是否顯示文字標籤。ShowLabel – Whether a text label is shown beside the toggle control.

TabIndex – 自訂控制項在設定為非零值時於執行階段的定位順序。TabIndex – Customizes the tab order of controls at runtime when set to a non-zero value.

TextPosition – 標籤位於切換控制項的左側還是右側。TextPosition – Whether the label is to the left or the right of the toggle control.

Tooltip – 使用者將滑鼠指標停留在控制項上方時所顯示的說明文字。Tooltip – Explanatory text that appears when the user hovers over a control.

TrueFill – 切換開啟時的切換填滿色彩。TrueFill – Toggle fill color when the toggle is on.

TrueHoverFill – 切換開啟時的切換暫留填滿色彩。TrueHoverFill – Toggle hover fill color when the toggle is on.

TrueText – 切換開啟時顯示的文字。TrueText – Text shown when the toggle is on.

ValueFill – 當切換控制項的值為 true 時,其矩形背景的色彩,或是滑桿控制項中控點左邊線條的色彩。ValueFill – The background color of the rectangle in a toggle control when its value is true or the color of the line to the left of the handle in a slider control.

ValueHoverFill – 將滑鼠指標停留在切換控制項或滑桿上時,當其值為 true 時矩形背景的色彩,或是滑桿控制項中控點左邊線條的色彩。ValueHoverFill – When you keep the mouse pointer on a toggle control or a slider, the background color of the rectangle in a toggle control when its value is true or the color of the line to the left of the handle in a slider 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).

If( Condition, Result )If( Condition, Result )

範例Example

  1. 新增切換,並命名為 MemberDiscountAdd a toggle, and name it MemberDiscount.

    不知道如何新增、命名和設定控制項嗎?Don't know how to add, name, and configure a control?

  2. 新增標籤,並將其 Text 屬性設定為下列公式:Add a label, and set its Text property to this formula:
    If(MemberDiscount.Value = true, "Price: $75", "Price: $100")If(MemberDiscount.Value = true, "Price: $75", "Price: $100")

    想要了解 If 函式或其他函式的詳細資訊嗎?Want more information about the If function or other functions?

  3. 按下 F5,然後變更 MemberDiscount 的值。Press F5, and change the value of MemberDiscount.

    標籤會顯示不同的價格,取決於 MemberDiscount 是為開啟或關閉。The label shows a different price, depending on whether MemberDiscount is on or off.

  4. 若要返回預設工作區,請按下 Esc 鍵。To return to the default workspace, press Esc.