2

I'm using the Microsoft RibbonControl on a UserControl (it needs to be so we can host it on a stub form to host the WPF in our MDI system). Sadly, the title of the Ribbon displays Top/Left in the ribbon's header, and it looks ridiculous. How do I get at that sucker?

Stu
  • 15,675
  • 4
  • 43
  • 74

1 Answers1

3

I am working on just about the same thing right now. I solved it by using a datatemplate for the ribbon title:

<r:Ribbon.TitleTemplate>
    <DataTemplate>
        <TextBlock Text="Put you title here" Margin="3,3,0,0"></TextBlock>
    </DataTemplate>
</r:Ribbon.TitleTemplate>

If the ribbon is used in a RibbonWindow, you probably also want to add a glow to the title text to be able to read it properly when placed over a dark background. In that case, add this XAML inside the TextBlock:

<TextBlock.BitmapEffect>
    <OuterGlowBitmapEffect GlowColor="White" Opacity="0.7" GlowSize="10"/>
</TextBlock.BitmapEffect>

There is one more problem with the Ribbon when used within a RibbonWindow; the title text will either be placed correctly when window state is Normal or when window is maximized. To solve this I bound the TextBlock Margin to a property in the codebind:

public Thickness TitleMargin
{
    get { return this.WindowState == WindowState.Maximized ? new Thickness(0, 3, 0, 0) : new Thickness(0); }
}

To get this working, you also need to fire a PropertyChanged event each time the window state changes:

protected override void OnStateChanged(EventArgs e)
{
    OnPropertyChanged("TitleMargin");
    base.OnStateChanged(e);
}
Christian Myksvoll
  • 634
  • 2
  • 7
  • 16
  • Nice, but BitmapEffect does not ever appear for me in the title template. Is there any reason? – arconaut Nov 23 '11 at 18:09
  • Yes, BitmapEffect has been deprecated and doesn't work anymore. It's not you. Sorry, I have no alternative for you other than weird DirectX effect hacks you might not want to use. – Stu Jan 01 '14 at 01:53