如何自定义 WPF Ribbon 4.5(样式、模板等) [英] How to customize the WPF Ribbon 4.5 (styles, templates, etc.)

查看:102
本文介绍了如何自定义 WPF Ribbon 4.5(样式、模板等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从 .Net Framework 4.5 自定义 System.Windows.Controls.Ribbon,以便它可以与 Expression Dark 主题(深色,如 Blend 的默认主题中的颜色)一起使用.我尝试了以下想法,但直到现在都没有任何进展:

I try to customize System.Windows.Controls.Ribbon from the .Net Framework 4.5 so it can be used with the Expression Dark theme (dark colors like in default theme of the Blend). I've tried following ideas, but until now without any progress:

  • 更改功能区的背景:将仅更改主要颜色,但保留所有其他光泽颜色、高光颜色等.
  • 更改样式和模板:我找不到任何默认模板功能区 4.5.我尝试通过 ShowMeTheTemplate 之类的工具获取它们,但似乎他们使用了一些内部类.
  • 使用 Blend for VS2012 自定义模板:我总是收到错误复制模板失败".
  • 使用 RibbonControlLibrary 中的 .net 4 功能区:RibbonWindow在 Windows 8 中看起来很难看(参见 WPF RibbonWindow + Windows 8 -控制箱看起来很糟糕),我无法解决
  • change the Background of the ribbon: will change only the main Color, but leaves all other glossy colors, highlight colos etc.
  • change the styles and templates: I couldn't find any default templates for the Ribbon 4.5. I've tried to get them via Tools like ShowMeTheTemplate, but it seems that they use some internal classes.
  • customizing the templates with Blend for VS2012: I get always an error "Copy Template failed."
  • use the .net 4 ribbon from the RibbonControlLibrary: the RibbonWindow Looks ugly in the Windows 8 (see WPF RibbonWindow + Windows 8 - control box looks bad), that I can't solve

任何帮助将不胜感激,欢迎所有建议.

Any help would be appreciated, all suggestions are welcome.

推荐答案

我能够使用 显示模板.为此,我对其进行了修改,以从System.Windows.Controls.Ribbon"(而不是主框架程序集)中提取模板.

I was able to extract a fully working template using Show me the templates. To do that I modified it to extract templates from "System.Windows.Controls.Ribbon" (rather than the main framework assembly).

它给了我以下内容:

https://gist.github.com/drayde/75526b570a266f5f8f38(太长无法粘贴在这里)

https://gist.github.com/drayde/75526b570a266f5f8f38 (too long to paste here)

只需将其添加到您的资源中并像这样使用它:

Just add this to your resources and use it like this:

    <Ribbon Template="{StaticResource ribbonTemplate}">
       ...
    </Ribbon>

通过修改模板,您应该可以完全控制功能区的显示方式.

By modifying the template you should have full control over how your ribbon is displayed.

这篇关于如何自定义 WPF Ribbon 4.5(样式、模板等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆