TextBlock.FontStyle 속성

정의

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

속성 값

FontStyle

원하는 글꼴 스타일을 지정하는 FontStyles 클래스의 멤버입니다. 기본값은 MessageFontStyle 값에 따라 결정됩니다.

예제

다음 예제에서는 설정 하는 방법을 보여 줍니다 합니다 FontStyle 특성을 TextBlock 요소입니다.

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

다음 예제에서는 설정 하는 방법의 FontStyle 속성 프로그래밍 방식으로 합니다.

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

설명

모든 FontStyle 자식 요소에 최상위 수준 설정을 재정의 합니다.

이 종속성 속성에는 사용 된 연결 된 속성에도 합니다. XAML에서 사용법은 <object TextBlock.FontStyle="value".../>개체 가 개체 요소(일반적으로 흐름 요소)TextBlock이며 은 클래스의 문자열 형식 속성 이름 FontStyles 중 하나입니다. 코드에서 연결 된 속성에서 지원 됩니다 GetFontStyleSetFontStyle입니다. 대부분의 요소 수 있는 연결 된 속성 일반적 이므로 포함 될를 TextBlock 연결 되지 않은 이와 유사한 지원 FontStyle 속성을는 TextBlock 렌더링에 사용 합니다.

종속성 속성 정보

식별자 필드 FontStyleProperty
메타 데이터 속성 설정 true AffectsMeasure, AffectsRender, Inherits

적용 대상