Control.FontStyle Control.FontStyle Control.FontStyle Control.FontStyle Property

定义

获取或设置字形。Gets or sets the font style.

public:
 property System::Windows::FontStyle FontStyle { System::Windows::FontStyle get(); void set(System::Windows::FontStyle value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.FontStyle FontStyle { get; set; }
member this.FontStyle : System.Windows.FontStyle with get, set
Public Property FontStyle As FontStyle

属性值

一个 FontStyle 值。A FontStyle value. 默认值为 NormalThe default is Normal.

示例

下面的示例演示如何设置控件的字体样式属性。The following example shows how to set the font style property of a control.

<Button Name="btn4" FontStyle="Normal" 
        Click="ChangeFontStyle">
  FontStyle
</Button>
void ChangeFontStyle(object sender, RoutedEventArgs e)
{
    if (btn4.FontStyle == FontStyles.Italic)
    {
        btn4.FontStyle = FontStyles.Normal;
        btn4.Content = "FontStyle";
    }
    else
    {
        btn4.FontStyle = FontStyles.Italic;
        btn4.Content = "Control font style changes from Normal to Italic.";
    }
}
Private Sub ChangeFontStyle(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    If (btn4.FontStyle = FontStyles.Italic) Then

        btn4.FontStyle = FontStyles.Normal
        btn4.Content = "FontStyle"

    Else

        btn4.FontStyle = FontStyles.Italic
        btn4.Content = "Control font style changes from Normal to Italic."
    End If
End Sub

注解

此属性仅影响其模板使用FontStyle属性作为参数的控件。This property only affects a control whose template uses the FontStyle property as a parameter. 在其他控件上, 此属性不会有任何影响。On other controls, this property has no impact.

依赖项属性信息Dependency Property Information

标识符字段Identifier field FontStyleProperty
元数据属性设置为trueMetadata properties set to true AffectsMeasure, AffectsRender, InheritsAffectsMeasure, AffectsRender, Inherits

适用于