PowerApps 中的标签控件Label control in PowerApps

一个框,显示文本、数字、日期或货币等数据。A box that shows data such as text, numbers, dates, or currency.

说明Description

标签按键入时原封不动地显示指定为文本字符串的数据,或显示指定为公式(计算结果为文本字符串)的数据。A label shows data that you specify as a literal string of text, which appears exactly the way you type it, or as a formula that evaluates to a string of text. 标签通常作为标识另一控件(如评分或音频控件)的标签出现在其他任何控件(如标识屏幕的横幅)之外,或出现在库中以显示项的特定类型信息。Labels often appear outside of any other control (such as a banner that identifies a screen), as a label that identifies another control (such as a rating or audio control), or in a gallery to show a specific type of information about an item.

关键属性Key properties

AutoHeight - 设置为 true 后,标签会自动调高高度,以显示配置的所有文本。AutoHeight – Set to true to allow the label to auto-grow its height to show all text configurated. 设置为 false 将文本截断至分配的高度。Set to false to truncate the text to the height assigned.

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

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

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

DelayOutput - 设置为 true,可在文本输入期间延迟操作。DelayOutput – Set to true to delay action during text input.

其他属性Additional properties

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

AutoHeight - 标签是否会在“Text”属性包含的字符数超过控件一次可显示的字符数时自动增加“Height”属性值。AutoHeight – Whether a label automatically increases its Height property if its Text property contains more characters than the control can show at one time.

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.

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.

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.

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

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

Overflow - 标签是否会在“Wrap”属性设置为“true”且“Text”属性值包含的字符数超过控件一次可显示的字符数时显示滚动条。Overflow – Whether a scrollbar appears in a label if its Wrap property is set to true and the value of the control's Text property contains more characters than the control can show at one time.

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.

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.

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.

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.

VerticalAlign – 控件上的文本相对于该控件垂直居中的位置。VerticalAlign – The location of text on a control in relation to the vertical center of that control.

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

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

Wrap - 太长而无法容纳在标签中的文本是否换到下一行。Wrap – Whether text that's too long to fit in a label wraps to the next line.

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

Text( Number, "FormatCodes" )Text( Number, "FormatCodes" )

示例Examples

显示文本字符串Show a literal string

  • 添加一个标签,然后将“Text”属性设置为“"Hello, world"”(含双引号)。Add a label, and set its Text property to "Hello, world" (including the double quotation marks).

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

显示公式的结果Show the result of a formula

  • 添加一个标签,然后将“Text”属性设置为如下公式:Add a label, and set its Text property to a formula such as this one:
    Today()Today()

    备注

    指定公式时,请勿使用引号,除非公式的参数是文本字符串。When you specify a formula, you don't use quotation marks unless an argument of the formula is a literal string. 在这种情况下,用双引号将参数(而不是公式)括住。In that case, enclose the argument, not the formula, in double quotation marks.

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

在此过程中,需创建一个名为 CityPopulations 的集合,其中包含欧洲各个城市人口的相关数据。In this procedure, you'll create a collection, called CityPopulations, that contains data about the population of various cities in Europe. 接下来,在包含三个标签的库中显示数据,然后指定每个标签将显示的数据类型。Next, you'll show that data in a gallery that contains three labels, and you'll specify the type of data that each label will show.

  1. 添加一个按钮,然后将其 OnSelect 属性设置为以下公式:Add a button, and set its OnSelect property to this formula:
    ClearCollect(CityPopulations, {City:"London", Country:"United Kingdom", Population:8615000}, {City:"Berlin", Country:"Germany", Population:3562000}, {City:"Madrid", Country:"Spain", Population:3165000}, {City:"Rome", Country:"Italy", Population:2874000}, {City:"Paris", Country:"France", Population:2273000}, {City:"Hamburg", Country:"Germany", Population:1760000}, {City:"Barcelona", Country:"Spain", Population:1602000}, {City:"Munich", Country:"Germany", Population:1494000}, {City:"Milan", Country:"Italy", Population:1344000})ClearCollect(CityPopulations, {City:"London", Country:"United Kingdom", Population:8615000}, {City:"Berlin", Country:"Germany", Population:3562000}, {City:"Madrid", Country:"Spain", Population:3165000}, {City:"Rome", Country:"Italy", Population:2874000}, {City:"Paris", Country:"France", Population:2273000}, {City:"Hamburg", Country:"Germany", Population:1760000}, {City:"Barcelona", Country:"Spain", Population:1602000}, {City:"Munich", Country:"Germany", Population:1494000}, {City:"Milan", Country:"Italy", Population:1344000})
  2. 按 F5,选择该按钮,然后按 Esc。Press F5, select the button, and then press Esc.
  3. 添加一个文本库,然后将其 Items 属性设置为 CityPopulationsAdd a text gallery, and set its Items property to CityPopulations.

    选择库后,右侧窗格显示该库的选项。When the gallery is selected, the right pane shows options for that gallery.

  4. Gallery1 窗格中,将顶部列表设置为 Population,中间列表设置为 City,底部列表设置为 CountryIn the Gallery1 pane, set the top list to Population, set the middle list to City, and set the bottom list to Country.