What do the following column / row measurements mean?

2

When creating WPF rows or columns, what does each of these measures mean?

<Grid.ColumnDefinitions>
  <ColumnDefinition Width="50"/>
  <ColumnDefinition Width="50*"/>
  <ColumnDefinition Width="*"/>
  <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
  • 50 - this I know is a fixed measure.
  • 50*
  • *
  • Auto
asked by anonymous 10.09.2016 / 04:05

1 answer

3

The asterisk indicates that the size must be proportional. The calculation is based on all values found in all asterisks of that group of elements.

In a way it is the way to use percentage indirectly. 100% is the sum of all the numbers of the group and there is proportional the percentage of each one according to its individual value. Some people like to make sure that the sum always results in 100, which is the percentage.

When you have fixed size elements - and you consider that Auto is fixed in size, that space is used independently. Only asterisks are counted in this count.

  • 50* - here is using 50 units (no matter what drive it is, just a number)
  • * - when not using a number is the same as using 1
  • Auto - the size will be adjustable according to what you have in the element, it can be varying if the internal "data" of it varies

In this example the first element will have 50 units and the last element will only be known according to the given element inside it. It is known that the second element will be 50 times larger than the third element. Then within the space left over for these two elements more than 98% will be occupied by the second element and less than 2% serpa occupied by the third.

Remember that WPF does not work with fixed number of points. It is calculated according to need. This unit used is completely virtual.

    
10.09.2016 / 04:39