Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set text at the head of a RibbonApplicationMenu

Tags:

I'm trying to have text in the top level of a RibbonApplicationMenu (trying to the get the word File there similar to Word or Outlook). It seems the Microsoft.Windows.Controls.Ribbon.RibbonApplicationMenu

MSDN

supports a SmallImageSource but no text property. Setting the Label property doesn't work for this problem.

xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"     <ribbon:RibbonApplicationMenu Label="File"><!--doesn't set the label --> </ribbon:RibbonApplicationMenu> 

The goal is to have the word "File" appear in the circled area below.

RibbonApplicationMenu

like image 879
Brian Triplett Avatar asked Jul 14 '11 18:07

Brian Triplett


1 Answers

The simplest solution (to me) was to insert a DrawingImage with a GlyphRun inside. On a separate post is asked how to get the AdvanceWidths and GlyphIndicies for the GlyphRun. The result is below

<ribbon:RibbonApplicationMenu.SmallImageSource>     <DrawingImage>         <DrawingImage.Drawing>             <GlyphRunDrawing ForegroundBrush="White">                 <GlyphRunDrawing.GlyphRun>                     <GlyphRun                             CaretStops="{x:Null}"                              ClusterMap="{x:Null}"                              IsSideways="False"                              GlyphOffsets="{x:Null}"                              GlyphIndices="41 76 79 72"                              FontRenderingEmSize="12"                              DeviceFontName="{x:Null}"                              AdvanceWidths="5.859375 2.90625 2.90625 6.275390625">                         <GlyphRun.GlyphTypeface>                             <GlyphTypeface FontUri="C:\WINDOWS\Fonts\SEGOEUI.TTF"/>                         </GlyphRun.GlyphTypeface>                     </GlyphRun>                 </GlyphRunDrawing.GlyphRun>             </GlyphRunDrawing>         </DrawingImage.Drawing>     </DrawingImage> </ribbon:RibbonApplicationMenu.SmallImageSource> 

Resulting Ribbon:

GlyphRun Result

like image 122
Brian Triplett Avatar answered Sep 22 '22 08:09

Brian Triplett