Bagikan melalui


Control.FontStyle Properti

Definisi

Mendapatkan atau mengatur gaya font.

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; }
[<System.ComponentModel.Bindable(true)>]
member this.FontStyle : System.Windows.FontStyle with get, set
Public Property FontStyle As FontStyle

Nilai Properti

Nilai FontStyle. Defaultnya adalah Normal.

Atribut

Contoh

Contoh berikut menunjukkan cara mengatur properti gaya font kontrol.

<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

Keterangan

Properti ini hanya memengaruhi kontrol yang templatnya menggunakan FontStyle properti sebagai parameter. Pada kontrol lain, properti ini tidak berdampak.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi FontStyleProperty
Properti metadata diatur ke true AffectsMeasure, , AffectsRenderInherits

Berlaku untuk