RibbonApplicationMenu - Label 设置不启作用

问题:I am using the WPF ribbon from October 2010, I would like to have the word "File" as the ApplicationMenu "label" similar to excel 2010.  I set the Label property but it does not seem to do anything.  I see there is a smallImageSource property but I jsut want to put text.

答案:Regarding to the first question, I checked the source code of the Ribbon controls (please download theMicrosoftRibbonForWPFSourceAndSamples from web site). In the theme file (\MicrosoftRibbonForWPFSourceAndSamples\RibbonControlsLibrary\Themes\Generic.xaml) of the ribbon

8072行附近, change the code:

 <!--<Image IsHitTestVisible="False"
    Source="{Binding RelativeSource ={RelativeSource FindAncestor, AncestorType ={x:Type ribbon:RibbonApplicationMenu}}, Path=SmallImageSource}"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Width="16"
    Height="16"
    RenderOptions.BitmapScalingMode="NearestNeighbor"
    RenderOptions.EdgeMode="Aliased" />-->
 <TextBlock Text="{TemplateBinding Label}"/>

8233行附近 change the code: 最后一行添加Label={TemplateBinding Label}

<ControlTemplate TargetType="{x:Type ribbon:RibbonApplicationMenu}">
   <Grid Focusable="False"
      x:Name="OuterGrid"
      SnapsToDevicePixels="True">
     <ribbon:RibbonToggleButton x:Name="PART_ToggleButton" 
       BorderBrush="{TemplateBinding BorderBrush}"
       Background="{TemplateBinding Background}"
       BorderThickness="{TemplateBinding BorderThickness}"                       
       Style="{StaticResource Ü}"
       FocusVisualStyle="{TemplateBinding FocusVisualStyle}"
       Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height}"
       Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width}"
       ToolTipTitle="{TemplateBinding ToolTipTitle}"
       ToolTipDescription="{TemplateBinding ToolTipDescription}"
       ToolTipImageSource="{TemplateBinding ToolTipImageSource}"
       ToolTipFooterTitle="{TemplateBinding ToolTipFooterTitle}"
       ToolTipFooterDescription="{TemplateBinding ToolTipFooterDescription}"
       ToolTipFooterImageSource="{TemplateBinding ToolTipFooterImageSource}"
       SmallImageSource="{TemplateBinding SmallImageSource}"
       IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}"
       Label="{TemplateBinding Label}"/>


 8393行附近 change the code: add code Label="{TemplateBinding Label}" 最后一行

<Canvas>
  <ribbon:RibbonToggleButton x:Name="PART_PopupToggleButton"
    AutomationProperties.Name="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(AutomationProperties.Name)}"
    Canvas.Top="-24"
    Canvas.Left="3"
    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen}"
    BorderBrush="{TemplateBinding BorderBrush}"
    Background="{TemplateBinding Background}"
    BorderThickness="{TemplateBinding BorderThickness}"                       
    Style="{StaticResource Ü}"
    Focusable="False"
    Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Height}"
    Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width}" 
    Label="{TemplateBinding Label}"/>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值