Я проверил исходный код элементов управления ленты (пожалуйста, загрузите
MicrosoftRibbonForWPFSourceAndSamples с веб-сайта ). в
файл темы
(\MicrosoftRibbonForWPFSourceAndSamples\RibbonControlsLibrary\Themes\Generic.xaml
)
Вы можете найти этот стиль "Ü
" используется для
RibbonApplicationMenu
. В этом стиле нет элемента для отображения
Текст, он имеет только один элемент Image для отображения изображения.
К счастью, мы могли бы изменить код стиля и добавить некоторые элементы управления в
стиль "Ü
". Пожалуйста, под кодом:
строка 7264, измените код:
<!--<Image IsHitTestVisible="False"
Source="{Binding RelativeSource ={RelativeSource FindAncestor, AncestorType ={x:Type ribbon:RibbonApplicationMenu}},
Path = SmallImageSource}»
HorizontalAlignment = "Центр"
VerticalAlignment = "Центр"
Ширина = "16"
Высота = "16"
RenderOptions.BitmapScalingMode = "NearestNeighbor"
RenderOptions.EdgeMode = "Aliased" /> ->
строка 7433, добавьте код Label="{TemplateBinding Label}"
в конце
RibbonToggleButton
элемент:
......
<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}"/>
строка 7564, добавьте код Label="{TemplateBinding Label}"
в конце
RibbonToggleButton
элемент:
......
<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"
Высота = "{Binding RelativeSource = {RelativeSource TemplatedParent}, путь = Высота}"
Width = "{Binding RelativeSource = {RelativeSource TemplatedParent}, Path = Width}"
Label = "{TemplateBinding Label}" />
А в RibbonWindow мы могли бы установить свойство Label RibbonApplicationMenu как:
<ribbon:RibbonApplicationMenu Label="File">
Сообщение на форуме содержало ZIP с измененными источниками, но ссылка больше не работает.