wpf 设置网格列的宽度/高度时,“自动”和“*”有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3164651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 21:54:19  来源:igfitidea点击:

What is the different between 'Auto' and '*' when setting width/height for a grid column?

wpf

提问by Nam G VU

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

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

回答by Samuel Hyman

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

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

In brief:
- Automeans size to column contentand
- *means size proportional to grid

简而言之:
-Auto表示与列内容的大小
- *表示与网格成比例的大小

Automeans 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.

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

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.

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