这是我写的代码:
<Grid>
<Grid.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</Grid.Resources>
<TextBlock Margin="3,0,3,0" VerticalAlignment="Center"
Text="Comment here..."
FontSize="12"
Foreground="Black"
Height="35"
Visibility="{Binding ElementName=TextBox1, Path=Text.IsEmpty,
Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBox Margin="0" Background="#AAFFFFFF"
VerticalAlignment="Top" Name="FilterTextBox"
Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}"
MinLines="2"
MaxLines="2"
BorderThickness="0"
VerticalScrollBarVisibility="Auto"
MaxLength="{Binding MaxLength}"
Height="35">
</TextBox>
</Grid>
如果我在此处输入任何删除注释的字母,这将按需要工作...但问题是我已将文本框设置为 MinLines = 2 并且滚动条可见,但两者都不起作用。我只能在一行中输入文字。谁能告诉我我做错了什么?或者有没有更好的方法在 wpf 中做到这一点?