在 XAML 中设计带有标签和输入的视图的最佳方法

RB8*_*B84 7 c# wpf xaml

每次有人要求我提供输入值的界面时,我发现自己创建了包含大量行和列的网格。试图寻找这个问题的答案,但发现很难

代码

 <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid.Resources>
                <Style TargetType="RowDefinition">
                    <Setter Property="Height" Value="25"/>
                </Style>
                <Style TargetType="TextBox">
                    <Setter Property="Margin" Value="2"/>
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="60"/>
                <ColumnDefinition Width="150"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0">Input 1</TextBlock>
            <TextBox Grid.Row="0" Grid.Column="1"></TextBox>
            <TextBlock Grid.Row="1" Grid.Column="0">Input 2</TextBlock>
            <TextBox Grid.Row="1" Grid.Column="1"></TextBox>
        </Grid>
Run Code Online (Sandbox Code Playgroud)

结果

例子

我想到的问题是是否有任何性能考虑,或者是否有另一种方法可以消除使用行号和列号维护属性的需要。

此处讨论了创建带有标签和输入的自定义控件的选项,但这会带来更多开销。

创建布局似乎有点重复,这让我想知道是否有一个工具可以做到这一点。

问题

这是最好的方法吗?如果不是,为什么以及应该如何做?