English 中文(简体)
• 如何使WPF方案与目前选定的Windows相吻合 主题
原标题:How to make a WPF program match the currently selected Windows Theme
  • 时间:2012-01-14 00:56:22
  •  标签:
  • c#
  • .net
  • wpf

我谨利用目前选定的系统主题,提出我的世界森林论坛申请。

举例来说,这里是我希望完成的视窗版。

“A

光盘 形式窗口有基本的菜单和专用工具。 如果用户选择改变主题,其出现将发生变化:

“same即绿色”/

Additionally, it will switch to areo theme when run in Windows 7. I would like to do the same in WPF. But I am unsure about how to make a WPF window styled after the current windows theme. This window (xaml), also has a menustrip and toolstrip control, but does not fully follow the selected Windows theme.

“WPF需要一些东西才能正确主题”/

菜单和工具禁运控制没有保留XPLuna专题中的梯度。 请注意,与网站。 这个问题似乎很接近尾声,但我想把所有控制的主题都与选定的系统主题相匹配,除非凌驾。 是否需要在控制的基础上这样做? 整个项目能否加以配置? http://blogs.msdn.com/b/wpfsdk/archive/2007/07/31/using-themes-with-custom-controls.aspx”rel=“nofollow noretinger”MSDN article仅涵盖习俗控制。

我将赞赏具体实例,说明如何使世界森林论坛门努和世界森林论坛工具禁运控制与目前的系统主题相吻合。

Edit: It would also be great to know what color to set the menu to such that a system themed stripe appears next to the menu item: (“Exit”左边)

“

(“Exit”左边)

最佳回答

问题是,WPF控制在内部与Windows表格中的一种或任何其他全球发展变化因素有很大的不同。 计生联控制线在网的不同班级的帮助下界定。 同样的主题可以简单地适用于它们。

Therefore I would say - yes, you should implement themeing on a per-control basis using the resource files in this question s answer.

我假定,我们是幸运的MS,为我们提供了所有的人。 另一种情况是,这些Xaml风格的存在本身证明,WPF框架更加令人信服。

The theme xaml files are in {Program Files}Microsoft ExpressionBlend 4SystemThemesWpf

你最初提到的问题有了一个例子,说明如何将这些问题与回答联系起来:。 视窗 《世界森林论坛》7个主题:

为摘取主题,您可以动态地从Application.Current.Resources.MergedDictionaries上添加/删除。

You will have to detect the current theme yourself.

问题回答

One way is to use system colors like these. They will change based on the theme accordingly. I m not sure if there s an easier way, but this is a good one =). There s a list below that shows you the colors per theme.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签