TextBlock.FontStyle Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit le style de police de niveau supérieur pour le TextBlock.
public:
property System::Windows::FontStyle FontStyle { System::Windows::FontStyle get(); void set(System::Windows::FontStyle value); };
public System.Windows.FontStyle FontStyle { get; set; }
member this.FontStyle : System.Windows.FontStyle with get, set
Public Property FontStyle As FontStyle
Valeur de propriété
Membre de la FontStyles classe spécifiant le style de police souhaité. La valeur par défaut est déterminée par la MessageFontStyle valeur.
Exemples
L’exemple suivant montre comment définir l’attribut FontStyle 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 FontStyle 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 FontStyle 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.FontStyle="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 dans la FontStyles classe. Dans le code, l’utilisation des propriétés jointes est prise en charge par GetFontStyle et SetFontStyle. 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 FontStyle , utilisée pour le TextBlock rendu.
Informations sur les propriétés de dépendance
| Élément | Valeur |
|---|---|
| Champ d’identificateur | FontStyleProperty |
Propriétés de métadonnées définies sur true |
AffectsMeasure, , AffectsRenderInherits |