如何制作Windows 8 XAML数据输入表单?

roy*_*yco 1 xaml windows-8

我需要在Windows 8上的XAML中创建一个表单来输入地址.我不需要"联系人"标题,但它应该是这样的:

在此输入图像描述

该示例来自IE的HTML5 Forms演示.

我尝试了一个2列网格,但TextBlocks和TextBoxes不容易排队.

最简单的方法是什么?

Dam*_*Arh 5

这就是你如何使用Grid这对我来说似乎是一个很好的解决方案:

<Grid Grid.Column="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <TextBlock Margin="2" Grid.Row="0" Text="Name:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="0" Grid.Column="1" Text="John Doe"/>
    <TextBlock Margin="2" Grid.Row="1" Text="Address:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="1" Grid.Column="1" Text="1 Microsoft Way"/>
    <TextBlock Margin="2" Grid.Row="2" Text="City:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="2" Grid.Column="1" Text="Redmond"/>
    <TextBlock Margin="2" Grid.Row="3" Text="State:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="3" Grid.Column="1" Text=""/>
    <TextBlock Margin="2" Grid.Row="4" Text="Zip Code:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="4" Grid.Column="1" Text="98052"/>
    <TextBlock Margin="2" Grid.Row="5" Text="Email Address:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="5" Grid.Column="1" Text="john.doe@microsoft.com"/>
    <TextBlock Margin="2" Grid.Row="6" Text="Telephone Number:" Style="{StaticResource BodyTextStyle}"/>
    <TextBox Margin="2" Grid.Row="6" Grid.Column="1" Text="(425) 333-4444"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

这是结果:

在此输入图像描述

不是TextBlocks和TextBoxes排队好吗?