首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在RibbonApplicationMenu上添加“文件”名称

在RibbonApplicationMenu上添加“文件”名称
EN

Stack Overflow用户
提问于 2020-06-23 08:35:09
回答 1查看 247关注 0票数 0

我是做WPF项目的新手。

我搜索了如何在RibbonApplicationMenu中添加文本--也许看起来,这个站点中也有相同的问题--但是相信我,我实现了它,但在我身上没有起作用。

我试过在我的<RibbonApplicationMenu>中放一个"File“名,我放了Label="File",但是它不起作用。接下来我能试试什么?

这里是我的XAML代码:

代码语言:javascript
运行
复制
             <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>

就像这张照片:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-23 09:02:12

这里有许多可能的(尽管很复杂)解决方案:How to set text at the head of a RibbonApplicationMenu

编辑

我测试了自己,只需在<RibbonApplicationMenu>之后立即添加这个

代码语言:javascript
运行
复制
<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>

给你的是:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62530615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档