您正在做的事情应该可以正常工作。您需要确保在父窗口上使用SizeToContent 属性。像这样的东西:
XAML
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Width="525" SizeToContent="Height">
<Grid Height="auto" >
<StackPanel Orientation="Vertical" >
<TextBlock Name="tb1" TextAlignment="Justify" TextWrapping="Wrap" Text="" />
<Grid Height="30">
<CheckBox VerticalAlignment="Center" Name="Random">Random CheckBox</CheckBox>
</Grid>
<Grid Height="auto">
<Button Name="button1" HorizontalAlignment="Right" Margin="0,0,80,0" Width="70" Height="30" Click="button1_Click" />
<Button Name="Button2" HorizontalAlignment="Right" Width="70" Height="30" Click="Button2_Click" />
</Grid>
</StackPanel>
</Grid>
</Window>
**代码隐藏”
private void button1_Click(object sender, RoutedEventArgs e)
{
tb1.Text += "TextBlock with contentes set at run-time. " +
"This text block should grow in height as necessary, " +
"and push the other controls down. The window itself " +
"should grow to \n\n Another paragraph\n";
}