gpt4 book ai didi

数据输入窗口的 WPF 最佳实践

转载 作者:行者123 更新时间:2023-12-03 14:59:17 25 4
gpt4 key购买 nike

我目前正在玩 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 方式!?

其他人如何布局复杂的数据输入窗口?

蒂亚

最佳答案

关于数据输入窗口的 WPF 最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/316921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com