PowerApps 中的计时器控件Timer control in PowerApps

一个控件,可确定特定时间后应用的响应方式。A control that can determine how your app responds after a certain amount of time passes.

说明Description

例如,计时器可确定控件显示的时长,或在经过特定时间后更改控件的其他属性。Timers can, for example, determine how long a control appears or change other properties of a control after a certain amount of time has passed.

请注意,必须先预览应用,然后计时器才能在设计器中运行。Note that you need to preview the app in order for Timer to run in the designer. 这样一来,用户可以在设计器中配置计时器,不受任何时间限制。This allows user to configure the timer in the designer without any time restrictions.

关键属性Key properties

Duration – 计时器运行的时长(毫秒计)。Duration – How long a timer runs in milliseconds. 不存在最大值。There is no maximum value.

OnTimerEnd - 计时器运行完毕时应用的响应方式。OnTimerEnd – How an app responds when a timer finishes running.

Repeat - 计时器运行完毕后是否自动重启。Repeat – Whether a timer automatically restarts when it finishes running.

其他属性Additional properties

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

AutoPause - 用户导航到另一屏幕时音频或视频剪辑是否自动暂停。AutoPause – Whether an audio or video clip automatically pauses if the user navigates to a different screen.

AutoStart - 用户导航到包含音频或视频控件的屏幕时,该控件是否自动开始播放剪辑。AutoStart – Whether an audio or video control automatically starts to play a clip when the user navigates to the screen that contains that 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.

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.

HoverBorderColor – 用户将鼠标指针停留在控件上时,该控件边框的颜色。HoverBorderColor – The color of a control's border when the user keeps the mouse pointer on that control.

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.

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

OnTimerStart - 计时器开始运行时应用的响应方式。OnTimerStart – How an app responds when a timer starts to run.

PressedBorderColor – 用户在点击或单击控件时,该控件边框的颜色。PressedBorderColor – The color of a control's border when the user taps or clicks 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.

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

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

Start - 是否播放音频或视频剪辑。Start – Whether an audio or video clip plays.

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

Text – 在控件上显示或用户键入到控件中的文本。Text – Text that appears on a control or that the user types into a control.

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).

Refresh( DataSource )Refresh( DataSource )

示例Examples

显示倒计时Show a countdown

  1. 添加一个计时器,并将其命名为 CountdownAdd a timer, and name it Countdown.

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

  2. 将计时器的 Duration 属性设置为 10000,其 RepeatAutostart 属性设置为 trueSet the timer's Duration property to 10000 and its Repeat and Autostart properties to true.
  3. (可选)通过以下方法可使计时器更易于读取:将其 Height 属性设置为 160Width 属性设置为 600,并将其 Size 属性设置为 60(optional) Make the timer easier to read by setting its Height property to 160, its Width property to 600, and its Size property to 60.
  4. 添加一个标签,然后将其 Text 属性设置为以下公式:Add a label, and set its Text property to this formula:
    "Number of seconds remaining: " & RoundUp(10-Countdown.Value/1000, 0)"Number of seconds remaining: " & RoundUp(10-Countdown.Value/1000, 0)

    想要了解有关 RoundUp 函数或其他函数的详细信息?Want more information about the RoundUp function or other functions?

    标签显示还有多少秒计时器重启。The label shows how many seconds remain before the timer restarts.

  5. (可选)将计时器的 Visible 属性设置为 false(optional) Set the timer's Visible property to false.

为控件添加动画效果Animate a control

  1. 添加一个计时器,并将其命名为 FadeInAdd a timer, and name it FadeIn.

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

  2. 将计时器的 Duration 属性设置为 5000,其 RepeatAutostart 属性设置为 trueSet the timer's Duration property to 5000 and its Repeat and Autostart properties to true.
  3. (可选)通过以下方法可使计时器更易于读取:将其 Height 属性设置为 160Width 属性设置为 600,并将其 Size 属性设置为 60(optional) Make the timer easier to read by setting its Height property to 160, its Width property to 600, and its Size property to 60.
  4. 添加一个标签,然后将“Text”属性设置为显示“Welcome!”Add a label, set its Text property to show Welcome! 并将其 Color 属性设置为以下公式:and set its Color property to this formula:
    ColorFade(Color.BlueViolet, FadeIn.Value/5000)ColorFade(Color.BlueViolet, FadeIn.Value/5000)

    想要了解有关 ColorFade 函数或其他函数的详细信息?Want more information about the ColorFade function or other functions?

    标签中的文本渐变为白色,恢复最大亮度,并重复此过程。The text in the label fades to white, returns to full intensity, and repeats the process.

  5. (可选)将计时器的 Visible 属性设置为 false(optional) Set the timer's Visible property to false.