WPF 网格布局

标签 wpf layout grid

是否可以在 WPF 中使用 Grid 设计类似的东西?设计列很容易,但是行呢?或者有没有更好的解决方案,比如另一个容器?将每个矩形想象成模块(GroupBox)。

Grid layout

最佳答案

用两列制作一个外部网格。在这个网格中,放置另外两个网格,每列一个。这将导致所需的布局。

这里举例说明如何做。请注意,我已经为高度放置了一些星星。根据您的需要更改它们。

<Grid>
 <Grid.ColumnDefinitions>
   <Grid.ColumnDefinition Width="*" />
   <Grid.ColumnDefinition Width="*" />
 <Grid.ColumnDefinitions>

 <Grid Grid.Column="0">
   <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
   </Grid.RowDefinitions>

   <!-- Here content elements of the first column -->

 </Grid>

 <Grid Grid.Column="1">
   <Grid.RowDefinitions>
      <RowDefinition Height="*"/>
      <RowDefinition Height="*"/>
   </Grid.RowDefinitions>

   <!-- Here content elements of the second column -->

 </Grid>


</Grid>

关于WPF 网格布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7432654/

相关文章:

iOS StackView 或 CollectionView

c# - 在Grid中使用Expander,扩展区域使用所有空间

wpf - Powershell中的WPF网格高度降低

c# - WPF + 在 TextBlock 中显示 bat 文件的输出

所有代码运行后显示的 C# 异步窗口

html - Internet Explorer 和 Google Chrome 的内容显示方式不同

android - 相对布局在 Android 4.4.4 上搞砸了

c# - 按下左/右键时防止焦点改变

wpf - 启动画面关闭后将主窗口置于前面

java - 如何在移动屏幕中水平和垂直居中 Framelayout