共用方式為


Control.FontFamily 屬性

定義

取得或設定控制項的字型系列。

public:
 property System::Windows::Media::FontFamily ^ FontFamily { System::Windows::Media::FontFamily ^ get(); void set(System::Windows::Media::FontFamily ^ value); };
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.Font)]
public System.Windows.Media.FontFamily FontFamily { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Font)>]
member this.FontFamily : System.Windows.Media.FontFamily with get, set
Public Property FontFamily As FontFamily

屬性值

FontFamily

字型系列。 預設值是系統對話方塊字型。

屬性

範例

下列範例示範如何設定控制項的字型系列屬性。

<Button Name="btn2" FontFamily="Arial" 
        Click="ChangeFontFamily">
  FontFamily
</Button>
void ChangeFontFamily(object sender, RoutedEventArgs e)
{

    ffamily = btn2.FontFamily;
    str = ffamily.ToString();
    if (str == ("Arial Black"))
    {
        btn2.FontFamily = new FontFamily("Arial");
        btn2.Content = "FontFamily";
    }
    else
    {
        btn2.FontFamily = new FontFamily("Arial Black");
        btn2.Content = "Control font family changes from Arial to Arial Black.";
    }
}
Private Sub ChangeFontFamily(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    ffamily = btn2.FontFamily
    str = ffamily.ToString()
    If (str = ("Arial Black")) Then

        btn2.FontFamily = New FontFamily("Arial")
        btn2.Content = "FontFamily"

    Else

        btn2.FontFamily = New FontFamily("Arial Black")
        btn2.Content = "Control font family changes from Arial to Arial Black."

    End If
End Sub

備註

此屬性只會影響範本使用 FontFamily 屬性做為參數的控制項。 在其他控制項上,此屬性不會有任何影響。

相依性屬性資訊

識別碼欄位 FontFamilyProperty
設定為 的中繼資料屬性 true AffectsMeasure, AffectsRender, Inherits

適用於