猿问

在 WPF 中排列项目

我有以下问题:

我的 TextBox 应该填满整个空间,但属性“VerticalAlignment="Stretch"” 不适合我。


这是我的代码:


<TextBox

x:Name="txt_in_ct_length_aisle"

Text="{Binding CtLengthAisle, UpdateSourceTrigger=PropertyChanged, 

      ValidatesOnDataErrors=True,NotifyOnValidationError=True}"

      Validation.Error="MainViewHasErrors"

      TextWrapping="Wrap" VerticalAlignment="Stretch" 

      KeyboardNavigation.TabIndex="0"/>

<Label x:Uid="LabelShowHint" Content="?" HorizontalAlignment="Right"/>

我应该如何正确设置属性?总而言之,我希望我的 TextBox 填充空间直到“?” 在右侧。


你们中的任何人都可以帮忙吗?


慕沐林林
浏览 134回答 1
1回答

Qyouu

您可以尝试使用具有两个控件的网格,并使用 Columns 属性对其进行控制。&nbsp; &nbsp; <Grid>&nbsp; &nbsp; <Grid.ColumnDefinitions>&nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="*"/>&nbsp; &nbsp; &nbsp; &nbsp; <ColumnDefinition Width="Auto"/>&nbsp; &nbsp; </Grid.ColumnDefinitions>&nbsp; &nbsp; <TextBox Grid.Column="0"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:Name="txt_in_ct_length_aisle"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Text="{Binding CtLengthAisle, UpdateSourceTrigger=PropertyChanged,&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ValidatesOnDataErrors=True,NotifyOnValidationError=True}"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Validation.Error="MainViewHasErrors"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TextWrapping="Wrap" VerticalAlignment="Stretch"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HorizontalAlignment="Stretch"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;KeyboardNavigation.TabIndex="0"/>&nbsp; &nbsp; <Label Grid.Column="1"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:Uid="LabelShowHint" Content="?" /></Grid>
随时随地看视频慕课网APP
我要回答