我有一个(简化的)2x2网格,里面有三个控件。左控制在两行上延伸。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GridSplitter Grid.Row="0" Grid.Column="1" Height="4" Background="Gray"
HorizontalAlignment="Stretch" VerticalAlignment="Bottom"></GridSplitter>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="2"
HorizontalAlignment="Left" VerticalAlignment="Stretch"></GridSplitter>
<!-- Simplified content -->
<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">Content</Button>
<Button Grid.Row="0" Grid.Column="1">Content</Button>
<Button Grid.Row="1" Grid.Column="1">Content</Button>
</Grid>
我无法弄清楚为什么这些分离器不起作用。
答案 0 :(得分:4)
我建议在内容
后面定义GridSplitter<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">Content</Button>
<Button Grid.Row="0" Grid.Column="1">Content</Button>
<Button Grid.Row="1" Grid.Column="1">Content</Button>
<GridSplitter Grid.Row="0" Grid.Column="1" Height="4" Background="Gray"
HorizontalAlignment="Stretch" VerticalAlignment="Bottom"></GridSplitter>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="2"
HorizontalAlignment="Left" VerticalAlignment="Stretch"></GridSplitter>
答案 1 :(得分:1)
这个适合我 -
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GridSplitter Grid.Row="1" Grid.Column="2" Height="4" Background="Gray"
HorizontalAlignment="Stretch" VerticalAlignment="Center"></GridSplitter>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="4" Background="Gray" Grid.RowSpan="3"
HorizontalAlignment="Center" VerticalAlignment="Stretch"></GridSplitter>
<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">Content</Button>
<Button Grid.Row="0" Grid.Column="2">Content</Button>
<Button Grid.Row="2" Grid.Column="2">Content</Button>
</Grid>