.NET 4.5 WPF 功能区的更改主题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13174403/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Theme of .NET 4.5 WPF Ribbon
提问by user667967
I am trying to change the theme of the new WPF Ribbon Controlfrom .NET Framework 4.5 and I am stuck.
我正在尝试从 .NET Framework 4.5更改新的WPF 功能区控件的主题,但我被卡住了。
I only managed to change some brushes(Background, Foreground, Border ...) but I seem to be unable to change the bright overlay and shadows.
我只设法更改了一些画笔(背景、前景、边框...),但我似乎无法更改明亮的叠加层和阴影。
I am happy to use a resource dictionary but I don't know which properties I need to set.
我很高兴使用资源字典,但我不知道我需要设置哪些属性。
I hope you can point me in the right direction, thank you much for your help!
我希望你能指出我正确的方向,非常感谢你的帮助!
回答by Striver
If you want to change anything more than the exposed properties of the Ribbon control (or any other control) e.g. Background, Foreground etc. you will have to edit the control's Template.
如果您想更改功能区控件(或任何其他控件)的公开属性以外的任何内容,例如背景、前景等,则必须编辑控件的模板。
In a control's template you can change almost anything that's part of the control's visual appearance.
在控件的模板中,您几乎可以更改控件视觉外观中的任何内容。
For more information on customizing a control's template have a look on this link: MSDN Styling & Templating
有关自定义控件模板的更多信息,请查看此链接:MSDN 样式和模板
回答by MohamedHamza
it is pretty simple, in your App.xaml you can define a Theme and assign this theme to any control you want. for example I had defined Office_Blue as my theme and assigned this theme only to my Button only as below:
这很简单,在您的 App.xaml 中,您可以定义一个主题并将该主题分配给您想要的任何控件。例如,我已将 Office_Blue 定义为我的主题,并将此主题仅分配给我的 Button,如下所示:
<Application.Resources>
<telerik:Theme x:Key="TelerikGlobalTheme">Office_Blue</telerik:Theme>
<Style BasedOn="{x:Null}" TargetType="{x:Type Button}">
<Setter Property="telerik:StyleManager.Theme" Value="{DynamicResource TelerikGlobalTheme}" />
</Style>
you can assign as many controls as you want to that defined theme as above.
您可以为上述定义的主题分配任意数量的控件。
回答by Aldracor
For anyone coming across this, you could look at third party controls like: Syncfusion's Ribbon(looks like the office theme)
对于遇到此问题的任何人,您可以查看第三方控件,例如:Syncfusion's Ribbon(看起来像办公室主题)
回答by Bhavik Patel
There are two themes as far as I know, one is for "Windows 7(default)" and the other is for "Office 2007 Blue". You can change the theme by adding a resouce dictionay to the window's resouces the source of which is the xaml file of the office 2007 Blue, like following:
据我所知,有两个主题,一个是“Windows 7(默认)”,另一个是“Office 2007 Blue”。您可以通过在窗口的资源中添加资源字典来更改主题,该资源的来源是 office 2007 Blue 的 xaml 文件,如下所示:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
You can copy the Office2007Blue.xaml to a new xaml file and modify it to create a custom theme, then reference it by following the same way as above.
您可以将Office2007Blue.xaml 复制到一个新的xaml 文件并修改它以创建自定义主题,然后按照与上述相同的方式引用它。
You could get more about Ribbon from here.
And if you want quick and easy solution then try this ready WPF Themes.
如果你想要快速简单的解决方案,那么试试这个现成的WPF 主题。

