Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am having problems with the Microsoft RibbonWindow in VS2010 when setting a background image. The close (X) button seems to be covered by the image - even if maximised so the buttons are visible unexpected things happen when clicking. (right clicking seems to work).

AXML Code below creates the problem. Removing the Grid.Background
tag solves it. But I would like to keep the image - any suggestions?

I've posted a similar question on the WPF forum at Microsoft Social in case it is unexpected behaviour[^]

axml
<ribbon:RibbonWindow x:Class="TestButtons.Images.RibbonWindow1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        Title="RibbonWindow1"
        x:Name="Window"
        Width="640" Height="480">
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush TileMode="None" ImageSource="MyImage.JPG" Stretch="None" AlignmentX="Left" AlignmentY="Top" />
        </Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

         <ribbon:Ribbon x:Name="Ribbon">
            <ribbon:RibbonTab x:Name="HomeTab"
                              Header="Home">
                <ribbon:RibbonGroup x:Name="Group1"
                                    Header="Group1">

                </ribbon:RibbonGroup>

            </ribbon:RibbonTab>
        </ribbon:Ribbon>
    </Grid>
</ribbon:RibbonWindow>
Posted
Updated 5-Jun-11 23:41pm
v3

The answer given by Bob Bao [MSFT] was to put the background image in a rectangle with IsHitTestVisible set to false.
basically

XML
<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

<Rectangle IsHitTestVisible="False" Grid.RowSpan="2" Margin="0,22,0,0">
    <Rectangle.Fill>
        <ImageBrush TileMode="Tile" ImageSource="images/MyImage.JPG" Stretch="None" AlignmentX="Left" AlignmentY="Top" />
    </Rectangle.Fill>
</Rectangle>     
<ribbon:Ribbon x:Name="Ribbon">
 
Share this answer
 
Add your image to the ribbon window instead of the grid:

<ribbon:ribbonwindow ...="" xmlns:ribbon="#unknown">
   <ribbon:ribbonwindow.background>
      <imagebrush tilemode="None" imagesource="MyImage.JPG" stretch="Fill" />
   </ribbon:ribbonwindow.background>

   <grid>
   .
   .
   .
   </grid>
</ribbon:ribbonwindow>
 
Share this answer
 
Comments
Erik Rude 20-Jan-12 11:21am    
The only issue with this solution is that it does not cover the Windows bar at the top.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900