2016-07-15 2 views
2

와 함께.확장기 내가 두 개의 "영역", 상단과 하단에 내 WPF 창을 분할하기 위해 노력하고있어 GridSplitter

  • 상단 영역은 그리드가 포함되어 있습니다.
  • 하단 영역은 확장이 포함되어 있습니다.

두 영역 사이에는 사용자가 영역 크기를 조정하는 데 사용할 수있는 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> 

두 가지 작동하지 않습니다 :

  • 확장기 가능한 모든 공간 (높이를 변경하지 않습니다)하지 않는 expander not using all space available

  • 확장기를 닫으면 GridSplitter는 맨 위 영역에서 사용 가능한 모든 공간을 사용할 수 없습니다. top area does not use all space available

어떻게이 일을 할 수

?

답변

2

GridSplitters과 상호 작용하면 모눈 행/열 정의에서 구체적인 상대 또는 절대 Height/Width 값을 설정합니다. 그래서 당신이 붕괴되면 Expander 당신은 행의 HeightGridLength.Auto에 설정해야합니다.

+0

도움 주셔서 감사합니다. 솔루션이 작동합니다. 하지만 다른 것을 바꾸어야했습니다 ... GridSplitter가 자체 행에있었습니다 ... 행을 제거하고 확장자가있는 행에 추가했습니다. – musium

관련 문제