TextBlock.Typography Właściwość

Definicja

Pobiera obecnie obowiązujące odmiany typografii dla zawartości tego elementu.

public:
 property System::Windows::Documents::Typography ^ Typography { System::Windows::Documents::Typography ^ get(); };
public System.Windows.Documents.Typography Typography { get; }
member this.Typography : System.Windows.Documents.Typography
Public ReadOnly Property Typography As Typography

Wartość właściwości

Typography Obiekt, który określa obecnie obowiązujące odmiany typografii. Aby uzyskać listę domyślnych wartości typografii, zobacz Typography.

Przykłady

W poniższym przykładzie pokazano, jak ustawić Typography atrybut TextBlock elementu.

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

W poniższym przykładzie pokazano, jak programowo ustawić Typography właściwość.

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

Uwagi

Właściwość Typography ma zastosowanie tylko do czcionek OpenType. Wariant typografii nie ma wpływu na czcionki, które nie obsługują wariantu. Aby uzyskać więcej informacji na temat tego tematu, zobacz Typografia w WPF.

Dotyczy

Zobacz też