This article briefly introduces the usage of controls in Windows Store applications. For convenience, we select representative controls in text controls and button controls for detailed description.
1. Text Control
(1) TextBlock
TextBlock is the most common text display control, focusing on the following attributes:
- CharacterSpacingThe uniform spacing before the characters. The spacing is equal to the font size/1000. The default value is 0. Positive values increase the tracking speed and increase the Character spacing. Negative values reduce the trace and tighten the character pitch.
- IsColorFontEnabledBoolean value to determine whether the color flag is displayed in color. True if the color flag is displayed in color; otherwise, false. The default value is true.
- LineStackingStrategyEnumeration value to determine the policy for the height of each row. There are three options: MaxHeight (default value), BaselineToBaseline, and BlockLineHeight. MaxHeight: the height of each row is determined by the maximum value of LineHeight and the natural height of the element. BaselineToBaseline: the height of each row is determined by the distance between the text baselines. BlockLineHeight: the height of each row is determined by LineHeight.
- OpticalMarginAlignmentEnumeration value, which specifies how to handle the edge value in each character layout when alignment with the border of the text container. There are two types: None (default value) and TrimSideBearings. None: uses the side orientation from the font layout value. TrimSideBearings: does not use the side position from the font layout value, and does not align the side of the font with the start position of the "ink" part.
- TextAlignmentEnumeration value, indicating the horizontal alignment of text content. There are four options: Left (default), Right, Center, and Justify. Left: Left alignment, Right: Right alignment, Center: Center, Justify: Intra-container alignment.
- TextLineBoundsEnumeration value, which affects the formula for calculating the Row Height. There are four types: Full (default), Tight, TrimToBaseline, and TrimToCapHeight. Full: the regular Row Height Calculation is used. Tight: The top height of the row indicates the font height, the bottom of the row indicates the text baseline, TrimToBaseline indicates the text baseline, and TrimToCapHeight indicates the text baseline: the top height of the row is the font height.
- TextTrimmingEnumeration value, used to take the rest action when the content overflow area. There are CharacterEllipsis, Clip, None (default), and WordEllipsis. CharacterEllipsis: trim text at the character boundary. The ellipsis (...) will be drawn (...) to replace the remaining text, Clip: trim the text at the pixel level, and crop excess fonts visually. None: Do not break the text, WordEllipsis: trim the text at the word boundary. The ellipsis (...) is drawn to replace the remaining text.
- TextWrappingEnumeration value, text line feed. There are three types: NoWrap, Wrap, and WrapWholeWords. NoWrap: no line feed. Wrap: the available width of the text line overflow container. Even if the last overflow is a single word, there is still a line break. The only difference between WrapWholeWords and Wrap is that there is no line break for a single word.