views:

1598

answers:

2

I have the following XAML code, which displays a picture (image inside borders) and a logo. Right now, the logo appears below the picture. This is expected, however my goal is to have the logo on top of the picture (precisely at the bottom-right corner). Does someone has an idea how to do that? Do we have layers in WPF?

Note: I absolutely need to keep the WrapPanel.

<WrapPanel>
    <Border BorderBrush="Gray" BorderThickness="1" Margin="3">
        <Border BorderBrush="White" BorderThickness="3">
            <Border BorderBrush="LightGray" BorderThickness="0.5">
                <Image Source="http://farm1.static.flickr.com/2/1703693_687c42c89f_s.jpg" Stretch="Uniform" />
            </Border>
        </Border>
    </Border>
    <Image Source="http://l.yimg.com/g/images/flickr_logo_gamma.gif.v59899.14" Height="10" />
</WrapPanel>
A: 

Put your picture and logo in a Canvas element and position them (Canvas.Top, Canvas.Left, etc) as needed.

David Brown
I must keep the WrapPanel...
Martin
The wrap panel makes items wrap, not overlap. Can you put the canvas inside the wrap panel?
John Batdorf
+6  A: 

You should be able to do something along the lines of:

<WrapPanel>
    <Grid>
        <Border BorderBrush="Gray" BorderThickness="1" Margin="3">
            <Border BorderBrush="White" BorderThickness="3">
                <Border BorderBrush="LightGray" BorderThickness="0.5">
                    <Image Source="http://farm1.static.flickr.com/2/1703693_687c42c89f_s.jpg" Stretch="Uniform" />
                </Border>
            </Border>
        </Border>
        <Image Margin="5" HorizontalAlignment="Right" VerticalAlignment="Bottom" Source="http://l.yimg.com/g/images/flickr_logo_gamma.gif.v59899.14" Height="10" />
    </Grid>
</WrapPanel>

By not specifying any rows or columns our grid places the 2 items in row 0 column 0 and stacks them on top of each other. The second image has Horizontal and Vertical alignment set to make it appear in the bottom right, and I've added a margin to the 2nd image to bump it up a bit, otherwise it sits on the border which I assume is not what you wanted?

Steven Robbins