gpt4 book ai didi

WPF:文本框不触发 onTextInput 事件

转载 作者:行者123 更新时间:2023-12-04 00:33:51 25 4
gpt4 key购买 nike

所以基本上,我有一堆用户可以填写的文本框。我有一个按钮,我想一直禁用它,直到所有的 TextBox 都输入了文本。这是我正在使用的示例 XAML 文本框:

<TextBox Name="DelayedRecallScore" TextInput="CheckTextBoxFilled" Width="24" />

这是我试图触发的功能:
  //Disables the OK button until all score textboxes have content
private void CheckTextBoxFilled(object sender, RoutedEventArgs e)
{
/*
foreach (TextBox scorebox in TextBoxList)
{
if (string.IsNullOrEmpty(scorebox.Text))
{
Ok_Button.IsEnabled = false;
return;
}
}
Ok_Button.IsEnabled = true;
*/
MessageBox.Show("THIS MAKES NO SENSE");
}

当 TextInput 应该被触发时,MessageBox 没有出现。作为一个实验,我尝试在 PreviewTextInput 上触发 CheckTextBoxFilled(),然后它运行良好,这意味着无论出于何种原因,该函数都没有被调用。我还有一个由 PreviewTextInput 触发的验证函数,它可以正常工作。起初我认为 PreviewTextInput 可能会以某种方式干扰 TextInput,所以我从 TextBox 中删除了 PreviewTextInput,但这并没有解决任何问题。我完全不明白为什么会发生这种情况,所以任何帮助将不胜感激。

最佳答案

您的 TextInput 处理程序事件未触发,因为 TextBox正在处理事件。您可以尝试使用 TextChanged取而代之的是事件,因为实际上您只想知道何时从 TextBox 中添加或删除了字符。 .

关于WPF:文本框不触发 onTextInput 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1374710/

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