0

I am new in making WPF projects.

I searched on how to add Text in RibbonApplicationMenu maybe it looks that, there's the same questions to this in this site but trust me I implemented it but didn't works in me.

I've tried putting a "File" name in my <RibbonApplicationMenu>, I put Label="File" but it doesn't work. What can I try next?

Here's my XAML code:

             <Ribbon x:Name="Ribbon">
                    <Ribbon.TitleTemplate>
                        <DataTemplate >
                            <TextBlock x:Name="FrontPageTitle" TextAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Ribbon}}, Path=Title}" Width="{Binding ElementName=RibbonWindow, Path=ActualWidth}" />
                        </DataTemplate>
                    </Ribbon.TitleTemplate>
                    <Ribbon.HelpPaneContent>
                        <RibbonButton SmallImageSource="pack://application:,,,/MYSEP;component/Images/window.png" />
                    </Ribbon.HelpPaneContent>
                    <Ribbon.QuickAccessToolBar>
                        <RibbonQuickAccessToolBar>
                            <RibbonButton x:Name="QATButton1" 
                                         SmallImageSource="pack://application:,,,/MYSEP;component/Images/window.png" />
                            <RibbonButton x:Name="QATButton2" 
                                         SmallImageSource="pack://application:,,,/MYSEP;component/Images/window.png" />
                        </RibbonQuickAccessToolBar>
                    </Ribbon.QuickAccessToolBar>
                    <Ribbon.ApplicationMenu>
                        <RibbonApplicationMenu Label="File">
                            <RibbonApplicationMenuItem Header="New Design Project"
                                                      x:Name="NewDesignProject"
                                                      ImageSource="pack://application:,,,/MYSEP;component/Images/newProject.png" Click="AddNewDesign"/>
                            <RibbonApplicationMenuItem Header="New Rating Project"
                                                      x:Name="NewRatingProject"
                                                      ImageSource="pack://application:,,,/MYSEP;component/Images/newProject.png" Click="AddNewRating"/>
                            <RibbonApplicationMenuItem Header="Open..."
                                                       x:Name="Open"
                                                       ImageSource="pack://application:,,,/MYSEP;component/Images/open.png" Click="OpenMysepProject"/>
                        </RibbonApplicationMenu>
                    </Ribbon.ApplicationMenu>
                    <RibbonTab x:Name="HomeTab" 
                              Header="Home">
                        <RibbonGroup x:Name="Group1" 
                                    Header="Project">
                            <RibbonButton x:Name="Button1"
                                         LargeImageSource="pack://application:,,,/MYSEP;component/Images/manageProject.png"
                                         Label="Manage Project" />
                        </RibbonGroup>
                        <RibbonGroup x:Name="Group2" 
                                    Header="Vessel">
                            <RibbonButton x:Name="Button2"
                                         LargeImageSource="pack://application:,,,/MYSEP;component/Images/addVessel.png"
                                         Label="Add Vessel Design Mode" />
                            <RibbonButton x:Name="Button3"
                                         LargeImageSource="pack://application:,,,/MYSEP;component/Images/info.png"
                                         Label="Add Vessel Rating Mode" />
                            <RibbonButton x:Name="Button4"
                                         LargeImageSource="pack://application:,,,/MYSEP;component/Images/delete.png"
                                         Label="Delete Vessel" />
                        </RibbonGroup>
                    </RibbonTab>
              </Ribbon>

Just like this image:

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
angel1108
  • 333
  • 4
  • 22
  • 1
    A number of possible (though complicated) solutions here: [https://stackoverflow.com/questions/6698191/how-to-set-text-at-the-head-of-a-ribbonapplicationmenu](https://stackoverflow.com/questions/6698191/how-to-set-text-at-the-head-of-a-ribbonapplicationmenu) – Corrado Barbero Jun 23 '20 at 08:50
  • I saw that too sir but my application cannot read ```RibbonApplicationMenu.SmallImageSource``` I cannot add ```.SmallImageSource``` . It says not found. – angel1108 Jun 23 '20 at 08:53
  • Refer to this [answer](https://stackoverflow.com/a/55851938/587690) you could re-template RibbonApplicationMenu to get the desired result. – Suresh Jun 23 '20 at 09:07

1 Answers1

2

A number of possible (though complicated) solutions here: How to set text at the head of a RibbonApplicationMenu

EDIT

I tested myself, just add this immediately after <RibbonApplicationMenu>:

<RibbonApplicationMenu.SmallImageSource>
    <DrawingImage>
        <DrawingImage.Drawing>
            <GeometryDrawing>
                <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="0,0,20,20"></RectangleGeometry>
                </GeometryDrawing.Geometry>
                <GeometryDrawing.Brush>
                    <VisualBrush Stretch="Uniform">
                        <VisualBrush.Visual>
                            <TextBlock Text="File" FontSize="16" Foreground="White" />
                        </VisualBrush.Visual>
                    </VisualBrush>
                </GeometryDrawing.Brush>
            </GeometryDrawing>
        </DrawingImage.Drawing>
    </DrawingImage>
</RibbonApplicationMenu.SmallImageSource>

And here you go:

enter image description here

  • Woah i feel so dumb. I didn't tried to put this after `````` because I thought I will add ```.SmallImageSource``` to `````` . You're the only one who says that I will add it after. Thank you so much. This is my first WPF project BTW. Thank you! – angel1108 Jun 23 '20 at 09:08