关闭

RibbonApplicationMenu - Label 设置不启作用

364人阅读 评论(0) 收藏 举报
分类:

问题: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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3333次
    • 积分:81
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:1篇
    • 译文:1篇
    • 评论:0条
    文章分类
    文章存档