Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://stackoverflow.com/questions/2884625/what-is-difference-between-and-auto-in-silverlight-grid-layout-definitio
- The key is that only the `*` rows participate in sharing the remaining space.
- In your example:
- ```xml
- <Grid.RowDefinitions>
- <RowDefinition Height="*" />
- <RowDefinition Height="2*" />
- <RowDefinition Height="3*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- ```
- ### Step 1: Measure the `Auto` row
- Suppose the grid is 600 pixels high, and the `Auto` row's content needs 120 pixels.
- The `Auto` row gets exactly **120 px**.
- Remaining height:
- ```
- 600 - 120 = 480 px
- ```
- ### Step 2: Add up the star weights
- The remaining rows have weights:
- * `*` = `1*`
- * `2*`
- * `3*`
- Total weight:
- ```
- 1 + 2 + 3 = 6
- ```
- This is where the **6** comes from.
- ### Step 3: Divide the remaining space
- Each "star" represents one equal share:
- ```
- 480 / 6 = 80 px per star
- ```
- Now allocate according to the weights:
- | Row | Weight | Fraction of remaining space | Height |
- | ---- | ------ | --------------------------- | ------ |
- | `*` | 1 | **1/6** | 80 px |
- | `2*` | 2 | **2/6 = 1/3** | 160 px |
- | `3*` | 3 | **3/6 = 1/2** | 240 px |
- Notice that:
- * First row: **1/6** because its weight is **1** out of a total of **6**.
- * Second row: **2/6 = 1/3**.
- * Third row: **3/6 = 1/2**.
- The fractions add up to 1:
- [
- \frac{1}{6}+\frac{2}{6}+\frac{3}{6}=\frac{6}{6}=1
- ]
- So the first row gets **1/6** of the remaining height simply because its star weight is **1** and the total star weight is **6**. In general, a row with `N*` receives:
- [
- \frac{N}{\text{sum of all star weights}}
- ]
- of the space left after all `Auto` (and fixed-size) rows have been measured.
Advertisement
Add Comment
Please, Sign In to add comment