将 Office 2007 主题应用于 WPF 应用程序

发布于 2024-08-06 09:21:18 字数 345 浏览 5 评论 0原文

我正在使用 WPF 工具包中的 RibbonControl。它有办公室蓝色、黑色和银色主题。但主题不适用于窗口中的控件。有什么解决办法吗?

我正在应用主题,

 <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml"/>
 </ResourceDictionary.MergedDictionaries>

但控件就像按钮,文本框没有改变。

I am using the RibbonControl from WPF toolkit. It has the Office Blue, Black and Silver themes. But the the theme is not applying for the controls in the window. Is there any solution for that?

I am aplying the theme like

 <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml"/>
 </ResourceDictionary.MergedDictionaries>

But the controls are like button, textbox are not chaged.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拿命拼未来 2024-08-13 09:21:18

您需要一个单独的资源字典来为各种控件提供 WPF 样式。我通过在各种应用程序上采样颜色来创建自己的颜色。这其实并不难,我花了几个小时。

如果您正在寻找快速简便的解决方案,请尝试 WPF 主题< /a>. Bureau Blue 主题看起来很像 Office 2007 蓝色。

You need a separate resource dictionary to provide WPF styles to various controls. I created my own, by sampling the colors on various apps. It's really not very hard to do, and it olny took me a couple of hours.

If you are looking for a quick and easy solution, try the WPF Themes. The Bureau Blue theme looks pretty much like Office 2007 blue.

以酷 2024-08-13 09:21:18

您打算如何应用该主题?您是否在 app.xaml 中应用它(如下所示)?

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
    <ResourceDictionary Source="/WPFToolkit;V3.5.31016.1;component/DataGrid/Themes/Aero.NormalColor.xaml" />
</ResourceDictionary.MergedDictionaries>

How are you trying to apply the theme? Are you applying it in your app.xaml (something like the below)?

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
    <ResourceDictionary Source="/WPFToolkit;V3.5.31016.1;component/DataGrid/Themes/Aero.NormalColor.xaml" />
</ResourceDictionary.MergedDictionaries>
烟燃烟灭 2024-08-13 09:21:18

我一直在尝试重用 RibbonControlsLibrary.dll 中定义的资源,以便我可以将类似的样式应用于应用程序的其余部分。经过几个小时的搜索和摆弄,这就是我意识到的:

<Rectangle Stroke="Black" StrokeThickness="2" RadiusX="6" RadiusY="6" HorizontalAlignment="Stretch" Width="Auto" Grid.RowSpan="3" Grid.ColumnSpan="3"
Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonBackgroundBrushKey}}" />

我通过查看资源字典中的键是什么并查看这篇文章得到了这个想法:
如何从 ComponentResourceKey 获取实际资源?< /a>

此方法允许我创建与所选功能区皮肤具有相同外观和感觉的其他样式。更改皮肤将重新设计应用程序的其他方面,例如按钮等......

I have been trying to reuse the resources that are defined in the RibbonControlsLibrary.dll so that I can apply a similar styling to the rest of my application. After hours of searching and fiddling, this is what I realised:

<Rectangle Stroke="Black" StrokeThickness="2" RadiusX="6" RadiusY="6" HorizontalAlignment="Stretch" Width="Auto" Grid.RowSpan="3" Grid.ColumnSpan="3"
Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonBackgroundBrushKey}}" />

I got the idea by looking at what the keys in the resource dictionary were and looking at this article:
How do I get the actual resource from a ComponentResourceKey?

This method allows me to create other styles that will have the same look and feel as the selected ribbon skin. Changing the skin will restyle the other aspects of the application, like buttons etc...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文