简体   繁体   English

WPF系统主题颜色

[英]WPF System Theme Colors

I'm trying to theme my WPF app to look like...a normal desktop app. 我正在尝试将WPF应用的主题设置为...普通的桌面应用。

I've seen other questions answered asking basically the same thing, but the solution doesn't seem to work for me. 我已经看到其他问题也回答了基本相同的问题,但是该解决方案似乎对我不起作用。 Suppose my menu bar is defined in XAML like so: 假设我的菜单栏是在XAML中定义的,如下所示:

<DockPanel>
    <Menu DockPanel.Dock="Top"
          Background="{DynamicResource {x:Static SystemColors.MenuBarBrushKey}}" />
</DockPanel>

(In actuality it also contains MenuItem entries, etc.) Running it on Windows 10---with no changes from the default theme---my menu bar is a grayish #f0f0f0 color. (实际上,它还包含MenuItem条目,等等。)在Windows 10上运行它-与默认主题没有任何更改-我的菜单栏是#f0f0f0灰色。 If I launch other (non-metro) apps, such as Notepad, Notepad++, Evernote, Maple, Snipping Tool, and so on, the menu bar is white: #ffffff. 如果我启动其他(非都市)应用程序,例如Notepad,Notepad ++,Evernote,Maple,Snipping Tool等,则菜单栏为白色:#ffffff。

Can someone point me in the correct direction for correctly using the Windows system colors? 有人可以指出我正确使用Windows系统颜色的正确方向吗?

WPF is a very customisable UI framework. WPF是一个非常可定制的UI框架。 By default, it doesn't really come 'themed' and the default looks pretty bad (opinion), but you are free to create any styles you want to adjust the look and feel of your application. 默认情况下,它并不是真正的“主题”主题,并且默认外观看起来很糟糕(意见),但是您可以自由创建任何想要调整应用程序外观的样式。

You need to either create styled controls for your application yourself, use some styles already created or build on top of a UI styling framework. 您需要自己为应用程序创建样式化的控件,使用已经创建的某些样式,或者在UI样式框架的基础上构建。

Windows 7 theme for WPF? WPF的Windows 7主题?

A codeplex containing a lot of free themes: http://wpfthemes.codeplex.com/ 包含许多免费主题的codeplex: http ://wpfthemes.codeplex.com/

Alternatively, you could build on top of a styling/theming framework. 或者,您可以在样式/主题框架的基础上构建。 One that I have used before and would recommend is MahApps Metro - it is a tool kit that can be used to make metro styled apps, the default styles look pretty awesome and there are a lot of already revamped/custom controls . 我以前使用过并推荐使用的是MahApps Metro-这是一个可用于制作Metro风格的应用程序的工具套件,默认样式看起来非常棒,并且有很多已经修改/自定义的控件 You can easily override styles from that library to create your own look. 您可以轻松地从该库中覆盖样式以创建自己的外观。 It also uses two base color schemes that are used throughout, allowing a very consistent and customisable feel throughout the application. 它还使用了两种基本的配色方案,从而在整个应用程序中提供了非常一致且可自定义的感觉。 There are alternative frameworks out there, but the ones I've found are mostly for 'Metro' themes. 那里有其他框架,但是我发现的框架主要是针对“地铁”主题的。

Modern UI for WPF WPF的现代UI

Elysium 极乐世界

You need a SystemColors class. 您需要一个SystemColors类。 And a good article of it's usage: SystemColors Reference . 很好的用法是: SystemColors Reference Have a nice read :) 有一个不错的阅读:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM