What does exactly the star in size terms in WPF mean?
相关问题
- VNC control for WPF application
- Tkinter Grid Columnspan ignored
- WPF Binding from System.Windows.SystemParameters.P
- Xamarin. The name 'authorEntry does not exist
- XAML: Applying styles to nested controls
In addition, you can leave out the "*" if that's the element of unit size. So using Pwninstein's code example, it would just be:
In a WPF Grid,
Width="*"
orHeight="*"
means proportional sizing.For example: to give 30% to column 1 and 70% to column 2 -
And likewise for rows -
The numbers do not have to be integers.
If the Width for RowDefinition (Height for ColumnDefinition) is omitted, 1* is implied.
In this example, column 1 is 1.5 times wider than column 2 -
You can mix auto-fit and fixed widths with * (proportional) widths; in that case the * columns are apportioned to the remainder after the auto-fit and fixed widths have been calculated -
we take following example.....
one grid and has 3 columns and each contain one button of size 100.
XAML Code is...
But actually its size is....
Conclusion:
Total size of grid is 600
"Auto" : Column is re-size with it's contains. (2nd column has button of width 100)
"*" : 1st column width is 3x of 3rd column.
If you have 2 columns like this:
it means that the first column is 10x wider than the second. It's like saying "10 parts column 1, and 1 part column 2."
The cool thing about this is that your columns will resize proportionally. Other options are:
Hope that helps!