您的位置:首页 > 移动开发

RibbonApplicationMenu - Label 设置不启作用

2013-12-02 19:27 411 查看
问题: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}"/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: