EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.
Ce sujet n'a pas encore été évalué - Évaluez ce sujet

TextBlock.LineStackingStrategy Property

April 12, 2014

Gets or sets a value that indicates how a line box is determined for each line of text in the TextBlock.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public LineStackingStrategy LineStackingStrategy { get; set; }
<TextBlock LineStackingStrategy="BlockLineHeight"/>
-or-
<TextBlock LineStackingStrategy="MaxHeight"/>

Property Value

Type: System.Windows.LineStackingStrategy
A 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.

LineStackingStrategy determining line heights.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Cela vous a-t-il été utile ?
(1500 caractères restants)
Merci pour vos suggestions.
Afficher:
© 2014 Microsoft. Tous droits réservés.