155

I cannot distinguish the different between Auto and * when setting width and height for a grid column.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
  • Seems like you're talking about grid rows/columns... they're not actually elements. – Noldorin Jul 02 '10 at 09:53
  • 1
    possible duplicate of [What is difference between " * " and "Auto" in Silverlight Grid Layout Definitions](http://stackoverflow.com/questions/2884625/what-is-difference-between-and-auto-in-silverlight-grid-layout-definition) – ChrisF Jul 02 '10 at 10:00
  • I know the duplicate I suggest is for Silverlight, but the syntax is the same for WPF. – ChrisF Jul 02 '10 at 10:00

1 Answers1

281

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.

Morse
  • 8,258
  • 7
  • 39
  • 64
Samuel Jack
  • 32,712
  • 16
  • 118
  • 155