TextBlock.FontStyle Eigenschap

Definitie

Hiermee haalt u de tekenstijl op het hoogste niveau op of stelt u deze in voor de 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

Waarde van eigenschap

Een lid van de FontStyles klasse waarin de gewenste tekenstijl wordt opgegeven. De standaardwaarde wordt bepaald door de MessageFontStyle waarde.

Voorbeelden

In het volgende voorbeeld ziet u hoe u het FontStyle kenmerk van een TextBlock element instelt.

<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>

In het volgende voorbeeld ziet u hoe u de eigenschap FontStyle programmatisch instelt.

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

Opmerkingen

Alle FontStyle instellingen op onderliggende elementen overschrijven deze instelling op het hoogste niveau.

Deze afhankelijkheidseigenschap heeft ook een gekoppeld eigenschapsgebruik. In XAML is <object TextBlock.FontStyle="value".../>het gebruik, waarbij het object een objectelement is (meestal een stroomelement) dat zich in een TextBlock, bevindt en de waarde een van de eigenschapsnamen in tekenreeksindeling in de FontStyles klasse is. In code wordt het gebruik van gekoppelde eigenschappen ondersteund door GetFontStyle en SetFontStyle. Het gebruik van gekoppelde eigenschappen is niet gebruikelijk, omdat de meeste elementen die kunnen worden opgenomen in een TextBlock ondersteuning voor een analoge niet-gekoppelde FontStyle eigenschap, die wordt TextBlock gebruikt voor rendering.

Informatie over afhankelijkheidseigenschappen

Item Waarde
Id-veld FontStyleProperty
Eigenschappen van metagegevens ingesteld op true AffectsMeasure, , AffectsRenderInherits

Van toepassing op