1

3 つの行を持つ Grid と、最初の 2 つの行の間に GridSplitter があります。3 行目にはボタンが含まれています。GridSplitter をウィンドウの中央または下部にドラッグすると、すべてが適切にサイズ変更されます。GridSplitter をウィンドウの上部にドラッグすると、2 行目のサイズが正しく変更されず、3 行目が途切れます。

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:clr="clr-namespace:System;assembly=mscorlib"
    Width="300" MinHeight="300"  >
  <Grid ShowGridLines="True">
    <Grid.RowDefinitions>
      <RowDefinition MinHeight="130" />
      <RowDefinition MinHeight="50" />
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Rectangle Grid.Row="0" Fill="Aquamarine"/>
    <GridSplitter Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="5" />
    <ScrollViewer Grid.Row="1" >
      <Rectangle Height="500" Fill="Orange"/>
    </ScrollViewer>
    <Button Grid.Row="2" Content="Close" Width="70" HorizontalAlignment="Right" Margin="5" Click="Close_Click"/>
  </Grid>
</Window>
4

1 に答える 1

0

行の MinHeight 値が原因です。

コードをテストしましたが、説明している問題は、スプリッターをドラッグしたときではなく、ウィンドウのサイズを変更したときに発生します。

2 番目のグリッドを作成し、ボタンを移動すると役立ちます。

コード:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:clr="clr-namespace:System;assembly=mscorlib"
    Width="300" MinHeight="300"  >
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid ShowGridLines="True">
            <Grid.RowDefinitions>
                <RowDefinition MinHeight="130" />
                <RowDefinition MinHeight="50" />
            </Grid.RowDefinitions>

            <Rectangle Grid.Row="0" Fill="Aquamarine"/>
            <GridSplitter Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="5" />
            <ScrollViewer Grid.Row="1" >
                <Rectangle Height="500" Fill="Orange"/>
            </ScrollViewer>

        </Grid>
        <Button Grid.Row="1" Content="Close" Width="70" HorizontalAlignment="Right" Margin="5"/>
    </Grid>
</Window>
于 2013-09-19T19:21:24.147 に答える