gpt4 book ai didi

wpf - 标签 WPF 中的内容对齐

转载 作者:行者123 更新时间:2023-12-04 10:39:31 25 4
gpt4 key购买 nike

我在标签中对齐文本时遇到了一个小问题

这是我的 xaml 代码

<GroupBox Header="Normal" Width="450" Height="150" Name="grpNormal">
<Canvas Name="cvsNormal" Width="440" Height="140">
<Label Name="lblStartRegNormal" Width="223" Content="Enter the starting reg number: " FontSize="16" Canvas.Left="2" Canvas.Top="15" HorizontalContentAlignment="Right" />
<TextBox Name="txtStartRegNormal" Height="40" Width="200" Canvas.Right="10" Canvas.Top="15"/>
<Label Name="lblEndRegNormal" Width="223" Content="Enter the ending reg number: " FontSize="16" Canvas.Left="5" Canvas.Top="65" HorizontalContentAlignment="Right"/>
<TextBox Name="txtEndRegNormal" Height="40" Width="200" Canvas.Right="10" Canvas.Top="65"/>
</Canvas>
</GroupBox>

这是输出

enter image description here

但是当我更改标签内容时,右侧的冒号未对齐

enter image description here

我在这里做错了什么?

最佳答案

<GroupBox Header="Normal" Width="450" Height="150" Name="grpNormal">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Name="lblStartRegNormal" Width="223" Content="Enter the starting reg number: " FontSize="16" HorizontalContentAlignment="Right" />
<TextBox Name="txtStartRegNormal" Grid.Column="1" Height="40" Width="200"/>
<Label Grid.Row="1" Name="lblEndRegNormal" Width="223" Content="Enter the ending reg number: " FontSize="16" HorizontalContentAlignment="Right"/>
<TextBox Name="txtEndRegNormal" Height="40" Grid.Row="1" Grid.Column="1" Width="200" />
</Grid>
</GroupBox>

它看起来像这样:

enter image description here

关于wpf - 标签 WPF 中的内容对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18824675/

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