首页 新闻 赞助 找找看

WPF Grid 设置行间距 和列间距

0
悬赏园豆:10 [已解决问题] 解决于 2012-07-06 22:26

如题 在WPF 中怎样设置Grid 行间距 和列间距 ? 不是行高和列宽

BoyLife的主页 BoyLife | 初学一级 | 园豆:18
提问于:2012-05-30 13:08
< >
分享
最佳答案
0

呵呵,和网页的不一样,没那个属性。

楼上已经说margin和padding,还有个笨办法,加空行空列。

收获园豆:3
xiaokang088 | 初学一级 |园豆:22 | 2012-06-29 16:45
其他回答(2)
0

使用margin 或者 padding填充

收获园豆:1
沦落的伤心人 | 园豆:208 (菜鸟二级) | 2012-05-30 13:26

   <Grid.RowDefinitions>
            <RowDefinition  ></RowDefinition>

  </Grid.RowDefinitions>

没有你说的那个属性

支持(0) 反对(0) BoyLife | 园豆:18 (初学一级) | 2012-05-30 14:19
0

Grid作为布局元素 好像没有这个必要吧

设置行间距 和列间距 干啥?

收获园豆:6
八戒的师傅 | 园豆:1472 (小虾三级) | 2012-06-03 12:36

这么说吧 上代码

  <Grid Name="gvMain">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
           
        </Grid.RowDefinitions>
        <Label Content="文章标题" Grid.Column="0" Grid.Row="0"  Margin="0,10,0,0"/>
        <TextBox  Grid.Column="1" Grid.Row="0" Margin="0,10,10,0" Name="txtTitle"  />
        <Label Content="文章关键字" Grid.Column="0" Grid.Row="1"   Margin="0,5,10,5"  />
        <TextBox  Grid.Column="1" Grid.Row="1" Margin="0,5,10,5" Name="txtKey"  />

像我上面的代码 我要实现文章标题和文章关键字这两行中间有间隔我就要设置每个控件的Margin属性 如果是多行多列的情况下这种方法不是很累 。所以我想实现在

<RowDefinition Height="auto"></RowDefinition> 中设置一下行间隔 不就会省很多工作。如果大神们有其他好的建议不妨提出来 我学习一下。

  <Grid Name="gvMain">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Label Content="文章标题" Grid.Column="0" Grid.Row="0"  Margin="0,10,0,0"/>
        <TextBox  Grid.Column="1" Grid.Row="0" Margin="0,10,10,0" Name="txtTitle"  />
        <Label Content="文章关键字" Grid.Column="0" Grid.Row="1"   Margin="0,5,10,5"  />
        <TextBox  Grid.Column="1" Grid.Row="1" Margin="0,5,10,5" Name="txtKey"  />

支持(0) 反对(0) BoyLife | 园豆:18 (初学一级) | 2012-06-04 17:12

@BoyLife: 个人建议

1、可以使用样式进行控制

2、Label、TextBox 不直接放,再统一的容器来装,然后在对容器使用样式进行控制

我也是刚学习不久,以上拙见,勿怪

支持(0) 反对(0) 八戒的师傅 | 园豆:1472 (小虾三级) | 2012-06-14 22:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册