检查多行文本框是否为空

本文关键字:是否 文本 检查 | 更新日期: 2023-09-27 18:04:29

我目前有以下XAML:

<TextBox Text="" x:Name="textFeedbackFeedback"
         Margin="11.593,0,29.307,42.96" TextWrapping="Wrap"
         VerticalContentAlignment="Top" VerticalAlignment="Bottom"
         Height="92.08" AcceptsReturn="True" VerticalScrollBarVisibility="Visible"/>

我试着用了很多不同的:

if(textFeedbackFeedback.text == "")
if(textFeedbackFeedback.text == null)
if(textFeedbackFeedback.text == string.Empty)
if(string.IsNullOrEmpty(textFeedbackFeedback.Text))

但是由于某种原因,它并没有停在那里,而是继续,好像那里有数据,有人能帮我一下吗?

谢谢。

检查多行文本框是否为空

try if(string.IsNullOrWhiteSpace(textFeedbackFeedback.Text))

如果这不起作用,试着找出文本的长度,以及文本中字符的整数/ascii值。

您可以尝试在文本上使用. trim()函数来消除可能存在的任何空白