Rick Rat
Rick Rat

Reputation: 1732

Buttons in the corners?

I'd like to have 4 buttons one in each corner of a WPF/Silverlight window. But I want the stuff in the grid/window to be "behind" the buttons, as if they float on top.

   <Grid x:Name="ButtonRoot"> 
        <Button VerticalAlignment="Top" HorizontalAlignment="Left" 
          Name="bTopLeft" /> 
        <Button VerticalAlignment="Top" HorizontalAlignment="Right" 
          Name="bTopRight" /> 
        <Button VerticalAlignment="Bottom" HorizontalAlignment="Left" 
          Name="bBottomLeft" /> 
        <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" 
          Name="bBottomRight" />

        <!-- Other junk here --> 
    </Grid> 

The problem is, the buttons will not be "over" things, as the things will "wrap" around the buttons. How do I achieve this effect?

Diagram of how I want it http://dl.compdj.com/images/stackButton.jpg

Upvotes: 0

Views: 180

Answers (2)

Jeff Wilcox
Jeff Wilcox

Reputation: 6385

Use two grids, remember whatever is farther down the file will be on top:

<Grid>
    <Grid Background="Green"><!-- put stuff here --></Grid>
    <Grid><!-- this goes on top -->
       <Button Width="50" Height="50" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Button" /><!-- top left button -->
       <!-- etc -->
    </Grid>
</Grid>

Upvotes: 5

Senad Meškin
Senad Meškin

Reputation: 13756

this should solve your problem
#bTopLeft { position: absolute; top: 0; left: 0; z-index: 1200; }

Upvotes: 0

Related Questions