我需要将图像和文本放到WPF功能区菜单中。我尝试了很少的东西,但我能得到的只是功能区菜单中的空按钮。我正在使用.NET framework 3.5。我工作代码的一部分在这里:
<r:Ribbon.ApplicationMenu>
<r:RibbonApplicationMenu Command="{StaticResource ApplicationMenuCommand}">
<r:RibbonApplicationMenu.Items>
<r:RibbonApplicationMenu>
<TextBlock Text="Some text"></TextBlock>
<Grid>
<Image Margin="2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120" Height="57" Source="Resources\Images\logo.png" />
</Grid>
</r:RibbonApplicationMenu>
</r:RibbonApplicationMenu.Items>
</r:RibbonApplicationMenu>
</r:Ribbon.ApplicationMenu>
提前感谢您的帮助。
答案 0 :(得分:2)
您可以使用ControlTemplate插入TextBlock,Image或其他元素。在代码中它看起来像:
<r:RibbonApplicationMenuItem>
<r:RibbonApplicationMenuItem.Template>
<ControlTemplate>
<Grid Width="500">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">
Text
</TextBlock>
<Image VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None"
Grid.Row="1" Source="/Application;component/Resources/Images/logo.png"/>
<StackPanel Orientation="Vertical" Grid.Row="2" >
<Label HorizontalAlignment="Center">
<TextBlock>
AnotherText
</TextBlock>
</Label>
</StackPanel>
</Grid>
</ControlTemplate>
</r:RibbonApplicationMenuItem.Template>
</r:RibbonApplicationMenuItem>
</r:RibbonApplicationMenu>