角落里的按钮?

时间:2010-05-23 19:53:28

标签: wpf silverlight xaml

我想在WPF / Silverlight窗口的每个角落都有4个按钮。但是我希望网格/窗口中的东西在按钮的“后面”,好像它们漂浮在顶部。

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

问题是,按钮不会“过度”,因为事物将“包裹”在按钮周围。我如何实现这种效果?

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

2 个答案:

答案 0 :(得分:5)

使用两个网格,记住文件中最下面的任何内容:

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

答案 1 :(得分:0)

这应该可以解决你的问题 #bTopLeft { position: absolute; top: 0; left: 0; z-index: 1200; }