2016-07-15 19 views
2

私はWPFウィンドウを上下2つの「エリア」に分割しようとしています。グリッドスプリッタと組み合わせたエクスパンダ

  • 上部領域にはグリッドが含まれています。
  • 下部にエキスパンダーがあります。

2つの領域の間には、ユーザーが領域のサイズを変更するために使用できるGridSplitterが必要です。
各領域の内容は、領域の全高を使用する必要があります。デフォルトでは

expected

、エキスパンダーが展開されます。
ユーザーがエキスパンダーを閉じると、下部の領域は折りたたまれたエクスパンダーの高さに縮小されます。

これは私のコードです:

<Window 
    x:Class="App.Shell" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    Title="Shell" Height="800" Width="1200"> 
    <Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <Grid Name="MainContentGrid"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="*" /> 
       <RowDefinition Height="Auto" /> 
      </Grid.RowDefinitions> 
      <!-- Top area --> 
      <Grid> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="*"></RowDefinition> 
        <RowDefinition Height="*"></RowDefinition> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="*"></ColumnDefinition> 
        <ColumnDefinition Width="*"></ColumnDefinition> 
       </Grid.ColumnDefinitions> 
       <Button Grid.Row="0" Grid.Column="0">1</Button> 
       <Button Grid.Row="1" Grid.Column="0">2</Button> 
       <Button Grid.Row="0" Grid.Column="1">3</Button> 
       <Button Grid.Row="1" Grid.Column="1">4</Button> 
      </Grid> 
      <GridSplitter Grid.Row="1" 
       HorizontalAlignment="Stretch" 
       VerticalAlignment="Top" 
       Background="Black" 
       ShowsPreview="true" 
       ResizeDirection="Rows" 
       Height="5"></GridSplitter> 
      <!-- Bottom area --> 
      <Expander Grid.Row="1" Margin="0,5,0,0" IsExpanded="True" Height="Auto" VerticalAlignment="Stretch"> 
       <Border Background="Red" Height="Auto" MinHeight="100" VerticalAlignment="Stretch"></Border> 
      </Expander> 
     </Grid> 
     <!-- Application Status Region --> 
     <ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.StatusRegion}" Grid.Row="1" /> 
    </Grid> 
</Window> 

2つのことが動作していません。

  • エキスパンダは、すべての利用可能なスペースをしません(その高さを変更しません) expander not using all space available

  • エキスパンダーを閉じると、GridSplitterは上部の領域で利用可能なすべてのスペースを使用することを許可しません。 top area does not use all space available

どのように私はこの作業を行うことができますか?

答えて

2

GridSplittersとやりとりすると、グリッドの行/列定義に具体的な相対または絶対/Widthの値が設定されます。したがって、Expanderを折り畳んだら、その行のHeightGridLength.Autoに設定する必要があります。

+0

ご協力いただきありがとうございます。 ソリューションは機能します。しかし、私は別のものを変更しなければなりませんでした... GridSplitterはそれ自体の行にありました...私はその行を削除し、それをエクスパンダを含む行に追加しました。 – musium