This topic has not yet been rated - Rate this topic

SystemFonts Class

Contains properties that expose the system resources that concern fonts.

System.Object
  System.Windows.SystemFonts

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
public static class SystemFonts

The SystemFonts type exposes the following members.

  Name Description
Public property Static member CaptionFontFamily Gets the metric that determines the font family of the caption of the nonclient area of a nonminimized window.
Public property Static member CaptionFontFamilyKey Gets the ResourceKey for the CaptionFontFamily property.
Public property Static member CaptionFontSize Gets the metric that determines the caption font-size for the nonclient area of a nonminimized window.
Public property Static member CaptionFontSizeKey Gets the ResourceKey for the CaptionFontSize property.
Public property Static member CaptionFontStyle Gets the metric that determines the caption font-style for the nonclient area of a nonminimized window.
Public property Static member CaptionFontStyleKey Gets the ResourceKey for the CaptionFontStyle property.
Public property Static member CaptionFontTextDecorations Gets the metric that determines the caption text-decorations for the nonclient area of a nonminimized window.
Public property Static member CaptionFontTextDecorationsKey Gets the ResourceKey for the CaptionFontTextDecorations property.
Public property Static member CaptionFontWeight Gets the metric that determines the caption font-weight for the nonclient area of a nonminimized window.
Public property Static member CaptionFontWeightKey Gets the ResourceKey for the CaptionFontWeight property.
Public property Static member IconFontFamily Gets the font family from the logical font information for the current icon-title font.
Public property Static member IconFontFamilyKey Gets the ResourceKey for the IconFontFamily property.
Public property Static member IconFontSize Gets the font size from the logical font information for the current icon-title font.
Public property Static member IconFontSizeKey Gets the ResourceKey for the IconFontSize property.
Public property Static member IconFontStyle Gets the font style from the logical font information for the current icon-title font.
Public property Static member IconFontStyleKey Gets the ResourceKey for the IconFontStyle property.
Public property Static member IconFontTextDecorations Gets the text decorations from the logical font information for the current icon-title font.
Public property Static member IconFontTextDecorationsKey Gets the ResourceKey for the IconFontTextDecorations property.
Public property Static member IconFontWeight Gets the font weight from the logical font information for the current icon-title font.
Public property Static member IconFontWeightKey Gets the ResourceKey for the IconFontWeight property.
Public property Static member MenuFontFamily Gets the metric that determines the font family for menu text.
Public property Static member MenuFontFamilyKey Gets the ResourceKey for the MenuFontFamily property.
Public property Static member MenuFontSize Gets the metric that determines the font size of menu text.
Public property Static member MenuFontSizeKey Gets the ResourceKey for the MenuFontSize property.
Public property Static member MenuFontStyle Gets the metric that determines the font style for menu text.
Public property Static member MenuFontStyleKey Gets the ResourceKey for the MenuFontStyle property.
Public property Static member MenuFontTextDecorations Gets the metric that determines the text decorations for menu text.
Public property Static member MenuFontTextDecorationsKey Gets the ResourceKey for the MenuFontTextDecorations property.
Public property Static member MenuFontWeight Gets the metric that determines the font weight for menu text.
Public property Static member MenuFontWeightKey Gets the ResourceKey for the MenuFontWeight property.
Public property Static member MessageFontFamily Gets the metric that determines the font family for message box text.
Public property Static member MessageFontFamilyKey Gets the ResourceKey for the MessageFontFamily property.
Public property Static member MessageFontSize Gets the metric that determines the font size of message box text.
Public property Static member MessageFontSizeKey Gets the ResourceKey for the MessageFontSize property.
Public property Static member MessageFontStyle Gets the metric that determines the font style for message box text.
Public property Static member MessageFontStyleKey Gets the ResourceKey for the MessageFontStyle property.
Public property Static member MessageFontTextDecorations Gets the metric that determines the decorations for message box text.
Public property Static member MessageFontTextDecorationsKey Gets the ResourceKey for the MessageFontTextDecorations property.
Public property Static member MessageFontWeight Gets the metric that determines the font weight for message box text.
Public property Static member MessageFontWeightKey Gets the ResourceKey for the MessageFontWeight property.
Public property Static member SmallCaptionFontFamily Gets the metric that determines the font family of the small-caption text for the nonclient area of a nonminimized window.
Public property Static member SmallCaptionFontFamilyKey Gets the ResourceKey for the SmallCaptionFontFamily property.
Public property Static member SmallCaptionFontSize Gets the metric that determines the font size of the small-caption text for the nonclient area of a nonminimized window.
Public property Static member SmallCaptionFontSizeKey Gets the ResourceKey for the SmallCaptionFontSize property.
Public property Static member SmallCaptionFontStyle Gets the metric that determines the font style of the small-caption text for the nonclient area of a nonminimized window.
Public property Static member SmallCaptionFontStyleKey Gets the ResourceKey for the SmallCaptionFontStyle property.
Public property Static member SmallCaptionFontTextDecorations Gets the metric that determines the decorations of the small-caption text for the nonclient area of a nonminimized window.
Public property Static member SmallCaptionFontTextDecorationsKey Gets the ResourceKey for the SmallCaptionFontTextDecorations property.
Public property Static member SmallCaptionFontWeight Gets the metric that determines the font weight of the small-caption text for the nonclient area of a nonminimized window.
Public property Static member SmallCaptionFontWeightKey Gets the ResourceKey for the SmallCaptionFontWeight property.
Public property Static member StatusFontFamily Gets the metric that determines the font family of the text used in status bars and ToolTips for the nonclient area of a nonminimized window.
Public property Static member StatusFontFamilyKey Gets the ResourceKey for the StatusFontFamily property.
Public property Static member StatusFontSize Gets the metric that determines the font size of the text used in status bars and ToolTips for the nonclient area of a nonminimized window.
Public property Static member StatusFontSizeKey Gets the ResourceKey for the StatusFontSize property.
Public property Static member StatusFontStyle Gets the metric that determines the font style of the text used in status bars and ToolTips for the nonclient area of a nonminimized window.
Public property Static member StatusFontStyleKey Gets the ResourceKey for the StatusFontStyle property.
Public property Static member StatusFontTextDecorations Gets the metric that determines the decorations of the text used in status bars and ToolTips for the nonclient area of a nonminimized window.
Public property Static member StatusFontTextDecorationsKey Gets the ResourceKey for the StatusFontTextDecorations property.
Public property Static member StatusFontWeight Gets the metric that determines the font weight of the text used in status bars and ToolTips for the nonclient area of a nonminimized window.
Public property Static member StatusFontWeightKey Gets the ResourceKey for the StatusFontWeight property.
Top

This example shows how to use the static resources of the SystemFonts class in order to style or customize a button.

System resources expose several system-determined values as both resources and properties in order to help you create visuals that are consistent with system settings. SystemFonts is a class that contains both system font values as static properties, and properties that reference resource keys that can be used to access those values dynamically at run time. For example, CaptionFontFamily is a SystemFonts value, and CaptionFontFamilyKey is a corresponding resource key.

In XAML, you can use the members of SystemFonts as either static properties or dynamic resource references (with the static property value as the key). Use a dynamic resource reference if you want the font metric to automatically update while the application runs; otherwise, use a static value reference.

Note Note

The resource keys have the suffix "Key" appended to the property name.

The following example shows how to access and use the properties of SystemFonts as static values in order to style or customize a button. This markup example assigns SystemFonts values to a button.


<Button Margin="10, 10, 5, 5" Grid.Column="0" Grid.Row="3"      
     FontSize="{x:Static SystemFonts.IconFontSize}"
     FontWeight="{x:Static SystemFonts.MessageFontWeight}"
     FontFamily="{x:Static SystemFonts.CaptionFontFamily}">
     SystemFonts
</Button>


To use the values of SystemFonts in code, you do not have to use either a static value or a dynamic resource reference. Instead, use the non-key properties of the SystemFonts class. Although the non-key properties are apparently defined as static properties, the run-time behavior of WPF as hosted by the system will reevaluate the properties in real time and will properly account for user-driven changes to system values. The following example shows how to specify the font settings of a button.


Button btncsharp = new Button();
btncsharp.Content = "SystemFonts";
btncsharp.Background = SystemColors.ControlDarkDarkBrush;
btncsharp.FontSize = SystemFonts.IconFontSize;
btncsharp.FontWeight = SystemFonts.MessageFontWeight;
btncsharp.FontFamily = SystemFonts.CaptionFontFamily;
cv1.Children.Add(btncsharp);


More Code

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ