<Window x:Class="TestringWpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="Yellow"></StackPanel>
<StackPanel Grid.Row="1" Background="Green">
<Button Margin="0,0,0,10000000000">ABC</Button>
</StackPanel>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
上面的代码将给我以下情况:

正如您所看到的,按钮在第二个时间被声明,StackPanel因此无论我如何设置边距,按钮都无法退出绿色背景.我想知道我该怎么做才能宣布按钮<StackPanel Grid.Row="1">并部分显示<StackPanel Grid.Row="0">.
总之,如何使元素在其容器中溢出并在另一个容器上重叠?可能吗?
另一种选择是a RenderTransform.
<Button Content="ABC">
<Button.RenderTransform>
<TranslateTransform Y="-50"></TranslateTransform>
</Button.RenderTransform>
</Button>
Run Code Online (Sandbox Code Playgroud)