Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...