Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF文本框自动增长_Wpf_Wpf Controls - Fatal编程技术网

WPF文本框自动增长

WPF文本框自动增长,wpf,wpf-controls,Wpf,Wpf Controls,我有一个高度为15,宽度为50的文本框。我希望文本框在文本大小超过50时增长。我希望在不使用Width=“Auto”的情况下实现这一点。有没有办法做到这一点?我尝试了TextWrapping=TextWrapping.Wrap,但没有成功 谢谢你的帮助 设置MinWidth=50假设您的文本框位于一个有两列的网格内 <Grid> <Grid.ColumnDefinitions> //The first column is used for a label &l

我有一个高度为15,宽度为50的文本框。我希望文本框在文本大小超过50时增长。我希望在不使用Width=“Auto”的情况下实现这一点。有没有办法做到这一点?我尝试了TextWrapping=TextWrapping.Wrap,但没有成功


谢谢你的帮助

设置MinWidth=50

假设您的文本框位于一个有两列的网格内

<Grid>
<Grid.ColumnDefinitions>

   //The first column is used for a label
  <ColumnDefinition Width="Auto"/>

//This column is used for your text box
 <ColumnDefinition Width="*"
                   MinWidth="25"/>
</Grid.ColumnDefinitions>

  <Label Grid.Column="0"
         Content="Something:"
  />
  <TextBox Grid.Column="1"
          Content="BindToProperty"
    />
</Grid>

//第一列用于标签
//此列用于文本框
用户控件的高度和宽度设置为

自动的

因此,每当您将用户控件放置到其他控件上时,它的最小宽度为

25+标签宽度

。如果要增加宽度,可以直接将宽度设置为用户控件,文本框将被拉伸

干杯