设置网格列的宽度/高度时,“自动"和“*"有什么区别? [英] What is the different between 'Auto' and '*' when setting width/height for a grid column?

查看:23
本文介绍了设置网格列的宽度/高度时,“自动"和“*"有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为网格列设置宽度/高度时,我无法区分自动"和*"之间的区别.请帮忙!

I cannot distinguish the different between 'Auto' and '*' when setting width/height for a grid column. Please help!

推荐答案

我们是在 WPF Grid 的上下文中讨论的?我的回答将讨论列,但同样适用于行.

We're talking in the context of WPF Grid here? My answer will talk about columns, but the same applies to rows.

简而言之:
- Auto 表示根据列内容调整大小
- * 表示大小与网格成正比

In brief:
- Auto means size to column content and
- * means size proportional to grid

Auto 意味着列的宽度与其中的元素所需的宽度相同.* 大小的列的宽度是通过为 Auto 和固定宽度的列分配空间,然后划分剩余空间来计算的.因此,如果只有一个 * 大小的列,它将获得所有剩余空间,如果有两个,它们将各获得一半,等等.您还可以更改分配给每个星号大小的列的比例.

Auto means that a column is given as much width as the elements within it require. The width of * sized columns is calculated by allocating space for the Auto, and fixed width columns, and then dividing up the remaining space. So if there's only one * sized column, it will get all the remaining space, if there were two they would get half each, etc. You can also change the proportion allocated to each star sized column.

如果A列的大小为2*,B列的大小为3*,那么整个列空间被分成5等份;A 列将获得 2 份空间,B 列将获得 3 份.

If column A had a size of 2* and B had a size of 3* then whole column space is divided into 5 equal shares; column A would get 2 shares of the space and B would get 3 shares.

这篇关于设置网格列的宽度/高度时,“自动"和“*"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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