Partage via


TextBlock.FontStretch Propriété

Définition

Obtient ou définit les caractéristiques d’étirement de police de niveau supérieur pour le TextBlock.

public:
 property System::Windows::FontStretch FontStretch { System::Windows::FontStretch get(); void set(System::Windows::FontStretch value); };
public System.Windows.FontStretch FontStretch { get; set; }
member this.FontStretch : System.Windows.FontStretch with get, set
Public Property FontStretch As FontStretch

Valeur de propriété

Membre de la FontStretch classe spécifiant les caractéristiques d’étirement de police souhaitées à utiliser. La valeur par défaut est Normal.

Exemples

L’exemple suivant montre comment définir l’attribut FontStretch d’un TextBlock élément.

<TextBlock 
  Name="textBlock"
  
  Background="AntiqueWhite" 
  Foreground="Navy" 
  
  FontFamily="Century Gothic"
  FontSize="12"
  FontStretch="UltraExpanded"
  FontStyle="Italic"
  FontWeight="UltraBold"
  
  LineHeight="Auto"
  Padding="5,10,5,10"
  TextAlignment="Center"
  TextWrapping="Wrap"
  
  Typography.NumeralStyle="OldStyle"
  Typography.SlashedZero="True"
>
  <Run Background="LightGreen">Text run 1.</Run>
  <LineBreak/><Run Background="LightBlue">Text run 2.</Run>
  <LineBreak/><Run Background="LightYellow">Text run 3.</Run>
</TextBlock>

L’exemple suivant montre comment définir la FontStretch propriété par programmation.

TextBlock textBlock = new TextBlock(new Run("A bit of text content..."));

textBlock.Background              = Brushes.AntiqueWhite;
textBlock.Foreground              = Brushes.Navy;

textBlock.FontFamily              = new FontFamily("Century Gothic");
textBlock.FontSize                = 12;
textBlock.FontStretch             = FontStretches.UltraExpanded;
textBlock.FontStyle               = FontStyles.Italic;
textBlock.FontWeight              = FontWeights.UltraBold;

textBlock.LineHeight              = Double.NaN;
textBlock.Padding                 = new Thickness(5, 10, 5, 10);
textBlock.TextAlignment           = TextAlignment.Center;
textBlock.TextWrapping            = TextWrapping.Wrap;

textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle;
textBlock.Typography.SlashedZero  = true;
Dim textBlock As New TextBlock(New Run("A bit of text content..."))

textBlock.Background = Brushes.AntiqueWhite
textBlock.Foreground = Brushes.Navy

textBlock.FontFamily = New FontFamily("Century Gothic")
textBlock.FontSize = 12
textBlock.FontStretch = FontStretches.UltraExpanded
textBlock.FontStyle = FontStyles.Italic
textBlock.FontWeight = FontWeights.UltraBold

textBlock.LineHeight = Double.NaN
textBlock.Padding = New Thickness(5, 10, 5, 10)
textBlock.TextAlignment = TextAlignment.Center
textBlock.TextWrapping = TextWrapping.Wrap

textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle
textBlock.Typography.SlashedZero = True

Remarques

Tous les FontStretch paramètres des éléments enfants remplacent ce paramètre de niveau supérieur.

Cette propriété de dépendance a également une utilisation des propriétés jointes. En XAML, l’utilisation est <object TextBlock.FontStretch="value".../>, où l’objet est un élément d’objet (généralement un élément de flux) contenu dans un TextBlock, et la valeur est l’un des noms de propriétés au format chaîne de la FontStretch classe. Dans le code, l’utilisation des propriétés jointes est prise en charge par GetFontStretch et SetFontStretch. L’utilisation des propriétés jointes n’est pas courante, car la plupart des éléments pouvant être contenus dans une TextBlock propriété de prise en charge non attachée FontStretch , utilisée pour le TextBlock rendu.

Informations sur les propriétés de dépendance

Élément Valeur
Champ d’identificateur FontStretchProperty
Propriétés de métadonnées définies sur true AffectsMeasure, , AffectsRenderInherits

S’applique à