2
세 개의 패널과 두 개의 스플리터 (수평 및 수직 스플리터)로 기본 WPF 레이아웃을 구현하고 싶습니다.스플리터가있는 스트레치 패널
왼쪽 및 아래쪽에있는 두 개의 패널은 호출 가능해야하며 그에 따라 하나의 패널이 늘어납니다.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Background="Aqua" Grid.Column="0" Name="leftPanel" >
<TextBlock FontSize="35" Foreground="#58290A" TextWrapping="Wrap">Left Hand Side</TextBlock>
</StackPanel>
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch"/>
<Grid Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Label Content="... Clien Area .. Has to Stretch vertically and horizontally" Margin="10"></Label>
<Button Click="LeftButton_Click" Margin="10">Close Left Panel</Button>
<Button Click="BottomButton_Click" Margin="10">Close Bottom Panel</Button>
</StackPanel>
<GridSplitter Grid.Row="1" Background="Gray" HorizontalAlignment="Stretch"/>
<ListBox Grid.Row="2" Background="Violet" Name="bottomPanel">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
</Grid>
및 코드 숨김 :.? :(주위에 모든 WPF 전문가가 클라이언트를 필요에 대한 해결책을 제시하는 예상대로
이private void LeftButton_Click(object sender, RoutedEventArgs e)
{
leftPanel.Visibility = (leftPanel.Visibility == System.Windows.Visibility.Visible)? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
}
private void BottomButton_Click(object sender, RoutedEventArgs e)
{
bottomPanel.Visibility = (bottomPanel.Visibility == System.Windows.Visibility.Visible) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
}
이 코드가 작동하지 않습니다 여기에
간단한 XAML입니다 동시에 (펼쳐지는) 스플리터?DockPanel은 완벽하게 작동하지만 스플리터가 필요합니다.
감사.
신속하고 정확한 답변 주셔서 감사합니다. 작동하지만 버그가 하나 있습니다. 나는 (스플리터 크기 조절)을 터치하면 즉시 작동을 멈 춥니 다. 그 이유는 너비 속성이 Auto에서 일부 크기로 변경 되었기 때문에 자동으로 너비를 바꿀 수있는 우아한 솔루션이라고 생각하십니까? – user1153896
내가 이런 식으로 뭔가를 할 때 GridSplitter 및 해당 열을 숨기면 한쪽이 접힐 때 주위에 놓을 필요가 없습니다. –