wpf XAML 网格中的 RowDefinition Height="10*" 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1164194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:45:11  来源:igfitidea点击:

What does RowDefinition Height="10*" mean in a XAML Grid?

wpfxamlgrid

提问by Edward Tanguay

I use Height="*" a bit to mean that the height of the last row should fill to the bottom of the grid.

我使用 Height="*" 表示最后一行的高度应该填充到网格的底部。

But what does "10*" mean?

但是“10*”是什么意思?

<Grid Name="mainGrid">
    <Grid.RowDefinitions>
        <RowDefinition Height="100" />
        <RowDefinition Height="40" />
        <RowDefinition Height="10*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200"  />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
</Grid>

回答by Kent Boogaart

"*"is shorthand for "1*". It's a ratio, so if you have two rows, one with "*"and one with "10*", the former gets 1/11th of the available and the latter gets 10/11th of the space.

"*"是 的简写"1*"。这是一个比率,所以如果你有两行,一排"*"和一排,"10*"前者占可用空间的 1/11,后者占空间的 10/11。

In your example above, "10*"is unnecessary - "*"would make more sense because there is only one row using ratio-based sizing, so any ratio will equate to 100% of the available space.

在上面的示例中,这"10*"是不必要的 -"*"更有意义,因为只有一行使用基于比率的大小调整,因此任何比率都将等于可用空间的 100%。

回答by Mario Levesque

I found the info below from Christian Mosers to be helpful since the Auto, and Fixed sizes on other cells rows or columns will influence the behavior of the * size. See http://wpftutorial.net/GridLayout.html

我发现以下来自 Christian Mosers 的信息很有帮助,因为其他单元格行或列上的自动和固定大小会影响 * 大小的行为。见http://wpftutorial.net/GridLayout.html



FixedFixed size of logical units (1/96 inch)

固定逻辑单元的固定大小(1/96 英寸)

AutoTakes as much space as needed by the contained control

自动根据所包含的控件的需要占用尽可能多的空间

Star(*) Takes as much space as available (after filling all auto and fixed sized columns), proportionally divided over all star-sized columns. So 3*/5* means the same as 30*/50*. Remember that star-sizing does not work if the grid size is calculated based on its content.

星号(*) 占用尽可能多的可用空间(在填充所有自动和固定大小的列之后),按比例分配给所有星号大小的列。所以 3*/5* 与 30*/50* 的意思相同。请记住,如果网格大小是根据其内容计算的,则星级调整不起作用。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="28" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="200" />
    </Grid.ColumnDefinitions>
</Grid>

回答by Inayat Ali Jan

In xaml *is used for percentage (%) so 10*means 10% of the total Grid. The row will use 10% of the grid

在 xaml*中,百分比 (%)10*表示总网格的 10%。该行将使用网格的 10%