来自 RibbonControlsLibrary 的造型功能区 [英] Styling Ribbon from the RibbonControlsLibrary

查看:33
本文介绍了来自 RibbonControlsLibrary 的造型功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

丝带很好.我想让它更好......(恕我直言)

Ribbon is nice. I want to make it nicer... (IMHO)

使用功能区(来自 .NET 3.5 sp1 上的 RibbonControlsLibrary),可以更改一些背景和前景.但我想要重新设计的是位于 RibbonTabGroup 的背景"中的白色面具"(带有 alpha 的线性渐变画笔).我和史努比一起看过.我在风格中找到了它.

With the Ribbon (from RibbonControlsLibrary on .NET 3.5 sp1), it is ok to change some backgrounds and foregrounds. But the thing I want to re-style is the white "mask" (linear gradient brush with alpha) that seats in the "background" of the RibbonTabGroup. I saw it with Snoop. I found it in the style.

<LinearGradientBrush x:Key="[49] Í" StartPoint="0.5,0.0" EndPoint="0.5,1.0">
    <GradientStop Color="#EEFFFFFF" Offset="0.0" />
    <GradientStop Color="#BBFFFFFF" Offset="0.1" />
    <GradientStop Color="#05FFFFFF" Offset="0.5" />
    <GradientStop Color="#20FFFFFF" Offset="1.0" />
</LinearGradientBrush>

但我仍然不知道如何覆盖它.我也不知道它在哪里设置...干杯,帕特里克

But still I have no idea how to override it. I don't know either where it is set... Cheers, Patrick

推荐答案

我明白了!

借助以下帖子 将 UserControl 序列化为 xaml,但不是它的孩子? [非常感谢你威尔].我可以提取默认"样式.所以我获得了完整的样式.我之前所做的是,使用 .NET Reflector 打开 RibbonControlsLibrary 并使用 BAML 查看器读取 XAML.对我来说并不理想.

With help of the following post Serialize a UserControl to xaml, but not its children? [Many thanks to you Will]. I could extract the "default" style. So I obtain the complete style. What I did before, open RibbonControlsLibrary with .NET Reflector and read the XAML with BAML Viewer. Not ideal in my case.

以防万一有人有同样的愿望,获取组件的默认样式(当它没有发布@MSDN时):

Just in case someone has the same wish, obtaining the default style of component (when it isn't published @MSDN):

  System.Windows.Style style = Application.Current.FindResource(typeof(Microsoft.Windows.Controls.Ribbon.Ribbon)) as System.Windows.Style;

  var sb = new System.Text.StringBuilder();
  var writer = System.Xml.XmlWriter.Create(sb, new System.Xml.XmlWriterSettings
  {
    Indent = true,
    ConformanceLevel = System.Xml.ConformanceLevel.Fragment,
    OmitXmlDeclaration = true
  });
  var mgr = new System.Windows.Markup.XamlDesignerSerializationManager(writer);
  mgr.XamlWriterMode = System.Windows.Markup.XamlWriterMode.Expression;
  System.Windows.Markup.XamlWriter.Save(style, mgr);
  string styleString = sb.ToString();

干杯,帕特里克

这篇关于来自 RibbonControlsLibrary 的造型功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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