列の幅または行の高さをスターに設定し、使用可能な長方形よりも大きいコンテンツを入力すると、行は「地下」で成長し続けます。
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="100" Width="100">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel>
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
<StackPanel Grid.Row="1"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.IsDeferredScrollingEnabled="True">
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
</Grid>
</Window>
StackPanelが地下に成長するのではなく、スクロールバーが表示されるようにしたいと思います。
親のサイズを変更するユーザーに応じてすべてが変わるように、すべてのサイズを動的にする必要があることに注意してください。
列についても同じ問題があります。
PS。RowDefinition.Heightは、デフォルトでは常に*です。
アップデート
問題はグリッドにあると思います。私が投稿した前のスニペットは全体像を提供していませんでした。確認してください。
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="200">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1">
<StackPanel>
<TextBlock Text="Hello"/>
<TextBox Text="World!"/>
</StackPanel>
<ScrollViewer>
<StackPanel>
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
</StackPanel>
</ScrollViewer>
</StackPanel>
</Grid>
</Window>