我目前正在使用 WPF,现在我想知道典型数据输入窗口(20 多个文本框和其他东西)的布局是什么。
atm 我正在使用这样的网格对象(基本示例)
<Grid Margin="2,2,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions >
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0">Vorname:</Label>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Surname, UpdateSourceTrigger=PropertyChanged}" ></TextBox>
<Label Grid.Row="1" Grid.Column="0">Nachname:</Label>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=ChristianName, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="2" Grid.Column="0">Strasse (Wohnsitz):</Label>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=Street1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="3" Grid.Column="0">Ort (Wohnsitz):</Label>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=Town1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="4" Grid.Column="0">Postleitzahl (Wohnsitz):</Label>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=PostalCode1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="5" Grid.Column="0">Bundesland (Wohnsitz):</Label>
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Path=State1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="6" Grid.Column="0">Land (Wohnsitz):</Label>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Path=Country1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="7" Grid.Column="0">Zusatz (Wohnsitz):</Label>
<TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=AdditionalAdrInfo1, UpdateSourceTrigger=PropertyChanged}"></TextBox>
</Grid>
基本上这满足了我所有的布局需求,但是如果我想改变一些东西,比如在第 3 行添加一个新的文本框呢?
目前我必须更改大于 3 的每个 Grid.Row 属性,但这不能是预期的 WPF 方式!?
其他人如何布局复杂的数据输入窗口?
蒂亚