如何在Windows Apps中使用 Gird ?
我想创建一个登录表单。我使用了网格并使用了但行没有正确对齐,我该怎么做?
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="67*"/> <ColumnDefinition Width="293*"/> </Grid.ColumnDefinitions> <StackPanel> <TextBlock Text="Name" Height="32" Margin="0,0,0.333,0" ></TextBlock> <TextBlock Text="Last Name" Height="30" Margin="0,0,0.333,0" ></TextBlock> <TextBlock Text="Address"></TextBlock> </StackPanel> <StackPanel Grid.Column="1"> <TextBox></TextBox> <TextBox></TextBox> <TextBox></TextBox> </StackPanel> </Grid>
答案 0 :(得分:2)
您应该在Grid中定义行和列。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="67*"/>
<ColumnDefinition Width="293*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="45"></RowDefinition>
<RowDefinition Height="45"></RowDefinition>
<RowDefinition Height="45"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="Name" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="Last Name" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="Address" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center"></TextBlock>
<TextBox Grid.Column="1" Grid.Row="0" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="1" Height="30"></TextBox>
<TextBox Grid.Column="1" Grid.Row="2" Height="30"></TextBox>
</Grid>