views:

72

answers:

1

Hi,

I need to put an image and text to WPF Ribbon Menu. I have tried few things but all I can get are empty buttons in Ribbon Menu. I am using .NET framework 3.5. Part of my not working code is here:

    <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>

Thanks in advance for any help.

A: 

You can insert TextBlock, Image or other elements by using ControlTemplate. In code it look like that:

 <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>
Cassandra