@DaisyTian-MSFT, this is the structure I'm using:
<Grid>
<Grid.Resources>
<Style TargetType="TextBox">
<Setter Property="Margin" Value="5 5 5 5"/>
</Style>
<Style TargetType="Border">
<Setter Property="Margin" Value="5"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderBrush="Black">
<ScrollViewer
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" />
<TextBox Grid.Row="1" />
<TextBox Grid.Row="2" />
<TextBox Grid.Row="3" />
<TextBox Grid.Row="4" />
<TextBox Grid.Row="5"
AcceptsReturn="True" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Text="TextBox that doesn't stretch vertically"/>
<TextBox Grid.Row="6" />
<TextBox Grid.Row="7" />
<Separator Grid.Row="8" Background="SkyBlue"/>
<TextBlock Grid.Row="9" Text="Error"/>
</Grid>
</ScrollViewer>
</Border>
<Border Grid.Row="1" BorderBrush="Blue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" />
<TextBox Grid.Row="1"
AcceptsReturn="True" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Text="TextBox that does stretch vertically"/>
</Grid>
</Border>
</Grid>
Here in the shortened version, the 6th Multiline TextBox
of the first Border
doesn't stretch vertically as long as the VerticalScrollbar
of the ScrollViewer
is visible:
But the 2nd Multiline TextBox
of the second Border
does.