2つの行とそれらの間にスプリッターがあるグリッドレイアウトが必要です。行の高さは80ピクセル以上にする必要があります。
このコードはうまく機能します:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="80" />
<RowDefinition Height="5" />
<RowDefinition Height="*" MinHeight="80" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<TextBlock Grid.Row="2" Text="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
</Grid>
ただし、ユーザーがスプリッターを使用して手動で変更するまで、一番上の行に自動高さを設定したいと思います。だから私はこれにコードを変更しました:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="80" />
<RowDefinition Height="5" />
<RowDefinition Height="*" MinHeight="80" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
<GridSplitter Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="Red" />
<TextBlock Grid.Row="2" Text="{Binding Path=ActualHeight, RelativeSource={RelativeSource Self}}" />
</Grid>
そして問題があります。スプリッターは引き続き行の制約を満たしますが、スプリッターを低くドラッグしすぎると、一番上の行の高さが無限に増加し始めます。これにより、一番下の行がウィンドウの下の境界線より完全に下になります。
GridSplitterコードでReflectorを実行しましたが、行の高さがAutoまたはStarの場合、異なるロジックを使用することがわかりました。
どうすればそれを「修正」できるかという提案はありますか?