开发者

Styling Ribbon from the RibbonControlsLibrary

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

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">
 开发者_StackOverflow   <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


I got it!

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.

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();

Cheers, Patrick

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜