网格星号在后面的代码
我有一个网格如下,
<Grid> <Grid.RowDefinitions> <RowDefinition Height="0.5*" /> <RowDefinition Height="0.5*" /> </Grid.RowDefinitions> </Grid>
我如何在代码中给出Height = "0.5*"
?
您可以使用:
rowDefinition.Height = new GridLength(0.5, GridUnitType.Star);
grid.RowDefinitions[0].Height = new GridLength(0.5, GridUnitType.Star);