gpt4 book ai didi

wpf - WPF中的Grid Splitter问题

转载 作者:行者123 更新时间:2023-12-03 23:11:00 25 4
gpt4 key购买 nike

我想要一个像 VS 2008 一样的布局。其中我想要两列,第二列再次分成两部分。

我在下面提到的 xaml 中做到了这一点,但是 GridSplitter垂直不可见(拆分两列)。
GridSplitter我都想要s 可调整大小。一 GridSplitter调整左手 Pane 和右手 Pane 的大小以及另一个 GridSplitter调整子网格的顶部 Pane 和右 Pane 的大小..

第二个GridSplitter正在处理此 XAML,但我无法生成拆分右侧 Pane 和左侧 Pane 的 XAML 代码。
请帮忙!!

<Window x:Class="AlarmUI_2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Background="Aqua" Grid.Column="0" >
<TextBlock FontSize="35" Foreground="#58290A"
TextWrapping="Wrap">Left Hand Side</TextBlock>
</StackPanel>
<GridSplitter Grid.Column="0" ResizeDirection="Auto"
Grid.RowSpan="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" Background="Red">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
<GridSplitter Grid.Row="1" Height="5" Background="Gray"
VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<ListBox Grid.Row="1" Background="Violet" Margin="0,5,0,0">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
</Grid>
</Window>

最佳答案

将您的垂直分配器更改为

<GridSplitter Grid.Column="0" Width="5" ResizeDirection="Auto" 
Grid.RowSpan="1"
HorizontalAlignment="Right"
VerticalAlignment="Stretch"/>

这将是使用 GridSplitter 的更好方法
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<StackPanel Background="Aqua" Grid.Column="0" >
<TextBlock FontSize="35" Foreground="#58290A"
TextWrapping="Wrap">Left Hand Side</TextBlock>


</StackPanel>

<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch"/>

<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" Background="Red">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
<GridSplitter Grid.Row="1" Background="Gray" HorizontalAlignment="Stretch"/>
<ListBox Grid.Row="2" Background="Violet">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
</Grid>

关于wpf - WPF中的Grid Splitter问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1748168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com