windows - 如何在通用 Windows 平台应用程序中实现 <Grid>?

标签 windows windows-store-apps uwp

如何在Windows Apps中使用Gird

I want to create a Login form. I have used grid and used but the Rows are not aligned properly, How can I do that?

<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>

最佳答案

您应该在 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>

关于windows - 如何在通用 Windows 平台应用程序中实现 <Grid>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32880470/

相关文章:

c# - UWP - 比较 JSON 和数据库上的数据

c# - VS2015 C# UWP 构建错误、共享项目和后台任务

c# - 在 C# 程序集中处理事件

c++ - C - Windows 函数(套接字)的编译错误

java - Windows 上的 Android jar/dex 方法计数

c# - 如何安装两个版本的 Metro 应用程序?

visual-studio-2013 - XAML 设计器错误 - 缺少智能感知

c++ - boost::filesystem::space() 报告错误的磁盘空间

c# - 如何访问 Windows 8.1 商店应用程序中子部分内的控件?在可视化树中搜索不起作用

c# - 如何提供 "object"并将其传递给 viewmodelbase?