TextBlock.LineStackingStrategy Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets a value that indicates how a line box is determined for each line of text in the TextBlock.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<TextBlock LineStackingStrategy="BlockLineHeight"/> -or- <TextBlock LineStackingStrategy="MaxHeight"/>
Property Value
Type: System.Windows.LineStackingStrategyA value that indicates how a line box is determined for each line of text in the TextBlock. The default is LineStackingStrategy.MaxHeight.
Dependency property identifier field: LineStackingStrategyProperty
The following example shows how to use the LineStackingStrategy property to determine how the line boxes are created for text lines of a TextBlock. The first TextBlock has a LineStackingStrategy value of MaxHeight and the second TextBlock has a value of BlockLineHeight.
<StackPanel> <!-- This TextBlock has a LineStackingStrategy set to "MaxHeight". --> <TextBlock FontFamily="Verdana" LineStackingStrategy="MaxHeight" LineHeight="10" Width="500" TextWrapping="Wrap" > Use the <Run FontSize="30">LineStackingStrategy</Run> property to determine how a line box is created for each line. A value of <Run FontSize="20">MaxHeight</Run> specifies that the stack height is the smallest value that contains all the inline elements on that line when those elements are properly aligned. A value of <Run FontSize="20">BlockLineHeight</Run> specifies that the stack height is determined by the block element LineHeight property value. </TextBlock> <!-- With a margin pushing down 20 pixels, draw a line just above the second textblock. --> <!-- The fonts will reach above the LineHeight size and over the line. --> <StackPanel Margin="0,20,0,0" HorizontalAlignment="Center"> <Line Stroke="Green" X2="500" /> </StackPanel> <!-- Here is the same TextBlock but the LineStackingStrategy is set to "BlockLineHeight". --> <TextBlock FontFamily="Verdana" LineStackingStrategy="BlockLineHeight" LineHeight="10" Width="500" TextWrapping="Wrap"> Use the <Run FontSize="30">LineStackingStrategy</Run> property to determine how a line box is created for each line. A value of <Run FontSize="20">MaxHeight</Run> specifies that the stack height is the smallest value that contains all the inline elements on that line when those elements are properly aligned. A value of <Run FontSize="20">BlockLineHeight</Run> specifies that the stack height is determined by the block element LineHeight property value. </TextBlock> </StackPanel>
The following illustration shows the result of the preceding code.
