【问题标题】:Using Microsoft Windows Standard Style in WPF-Window?在 WPF-Window 中使用 Microsoft Windows 标准样式?
【发布时间】:2010-01-19 14:38:19
【问题描述】:

是否可以在 WPF 窗口中使用 Microsoft Windows 标准样式?如果我用文本块或类似的东西创建一个普通的 WPF 窗口,字体会非常小,与 Microsoft Windows 中的不同。窗口的背景是白色的。也许您可以告诉我如何使用样式或信息源或类似的东西,我可以在其中读取 Microsoft Windows 标准窗口的设置,例如:

  • 字体系列/大小
  • 边距(在按钮、窗口、组框等中)
  • 填充物
  • 颜色(背景色,..)
  • 等等..

【问题讨论】:

标签: wpf window styles


【解决方案1】:

如果您正在为您的应用程序寻找系统定义的值,请查看以下 3 个类:

示例(来自 MSDN):

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);

或者,在 XAML 中:

<Button
     FontSize="{x:Static SystemFonts.IconFontSize}"
     FontWeight="{x:Static SystemFonts.MessageFontWeight}"
     FontFamily="{x:Static SystemFonts.CaptionFontFamily}"
     Background="{x:Static SystemColors.HighlightBrush}">
     SystemFonts 
</Button>

查看 MSDN 上的这些链接了解更多信息:System.Windows.SystemFontsSystem.Windows.SystemParametersSystem.Windows.SystemColors

快速提示:使用 Visual Studio IntelliSence 查看这些类中的属性列表

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    • 2021-05-03
    • 1970-01-01
    • 2012-09-12
    • 2016-03-12
    • 1970-01-01
    相关资源
    最近更新 更多