2010-05-23 112 views
0

我想在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

回答

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

這應該解決您的問題
#bTopLeft { position: absolute; top: 0; left: 0; z-index: 1200; }

+0

爲每個按鈕創建CSS – 2010-05-23 20:04:12

+0

這是WPF和XAML,而不是CSS。不過謝謝你。我正在解釋如何在html中執行此操作,但我需要在xaml中執行此操作。 – 2010-05-23 20:15:22