RibbonApplicationMenu - Label 设置不启作用

来源:互联网 发布:游戏制作软件大全 编辑:程序博客网 时间:2024/05/17 06:57

问题: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}"/>


原创粉丝点击