使用自动尺寸设置方式,可使用Auto值。表示自动适应显示内容的宽度, 如文本需要多长,控件就显示多长.如果存在显示不全的问题,就会截断显示。
<RowDefinition Height="Auto"></RowDefinition>
按比例尺寸设置方式,需要使用星号(*)
<RowDefinition Height="*"></RowDefinition>
如果界面中既有Auto又有*, 先分配Auto,最后分配*
直接上例子:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBox Margin="10" Grid.Row="0">This is a test.</TextBox>
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="10,10,2,10" Padding="3">OK</Button>