2
3つのパネルと2つのスプリッタ(水平スプリッタと垂直スプリッタ)で基本的なWPFレイアウトを実装したいと思います。スプリッタ付きストレッチパネル
左側と下側の2つのパネルは、呼び出し可能にする必要があり、1つのパネルはそれに応じてストレッチする必要があります。
<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>
と分離コード::。予想通り
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;
}
このコードの周り:(任意WPFの専門家が動作しないクライアントを持つための解決策を提案する?ここで
は、単純なXAMLがありますエリア(ストレッチ)とスプリッタは同時にですか?
DockPanelは完全に機能しますが、スプリッタが必要です。
ありがとうございます。
ありがとうございました。それは動作しますが、バグが1つあります。私が(スプリッターのサイズ変更)をタッチすると、即座に動作を停止します。理由は、幅プロパティがAutoからある程度のサイズに変更されていると思います。したがって、Autoに幅をスワップするためのエレガントなソリューションはありますか? – user1153896
このようなことをすると、GridSplitterとその列が隠れてしまいます。片方が折りたたまれていると、周囲に何の問題もありません。 –