了解统一网格控制 [英] Understanding Uniform Grid control

查看:112
本文介绍了了解统一网格控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在尝试统一网格,它是如何工作的.

I was just trying uniform grid, how it works.

代码:

<UniformGrid Name="uniformGrid1" Rows="2" Columns="3">
        <Button Content="Rohit" Grid.Row="0" Grid.Column="0" />
        <Button Content="asit" Grid.Row="0" Grid.Column="2" />
</UniformGrid>

我发现两个按钮彼此相邻放置,但是它们之间存在一列.为什么会这样呢? (就像在统一网格中一样,每个像元的大小相似,它们之间应该有一个像元)

I found that both buttons are placed adjacent to each other, however there exist a column between them. Why is it so ? (as in uniform grid, each cell has similar size there should be one cell between them)

了解为什么会这样(通过回答),但仍然想知道附加属性的意义是什么- Grid.Row& Grid.Column ,如果他们什么都不做?

Understood why it is so (by answer) but still curious to konw what's the significance of Attached property - Grid.Row & Grid.Column if they do nothing ???

推荐答案

UniformGrid包含两个属性,行和列,用于设置行和列的数量. 控件按照声明的顺序添加到网格中. 因此,它们之间将没有任何列.在您的示例中,您已声明Columns = 3,并且仅添加了两个控件.但是,如果添加另一个控件,它将放在最后.

UniformGrid contains two properties, Rows and Columns, for setting the number of rows and columns. Controls are added to the grid in the order that they are declared. So there will not be any column in between them. In your example you have declared Columns=3 and you have added only two controls. But if you add another control it will place in the end.

  <UniformGrid Name="uniformGrid1"
                 Rows="2"
                 Columns="3">
        <Button Content="Rohit"
                 Margin="2" />
        <Button Content="asit"
                 Margin="2" />
        <Button Content="asit"
                Margin="2" />
    </UniformGrid>

这篇关于了解统一网格控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆