2010-05-23 115 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