Control.FontFamily 属性

定义

获取或设置控件的字体系列。Gets or sets the font family of the control.

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; }
member this.FontFamily : System.Windows.Media.FontFamily with get, set
Public Property FontFamily As FontFamily

属性值

字体系列。A font family. 默认值是系统对话框字体。The default is the system dialog font.

属性

示例

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

<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属性作为参数的控件。This property only affects a control whose template uses the FontFamily property as a parameter. 在其他控件上, 此属性不会有任何影响。On other controls, this property has no impact.

依赖项属性信息Dependency Property Information

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

适用于