问题描述
基本上,我在屏幕上有一些TextBox和一个执行命令的按钮。每个TextBox都绑定到类型不同的特定属性。例如,一个TextBox绑定到Double属性。 WPF的美妙之处在于,当
不是Double的值输入TextBox时,TextBox以红色标出。太棒了!
但是,有没有办法检测其中一个TextBox何时显示非法值?
最终,我想制作根据具有"非法值"的一个或多个TextBox的事实启用或禁用按钮的命令。概述他们。我不知道是否有一个内置的方法来使用WPF。有时
我只是为了实现某些事情而花费很长时间来实现WPF已经内置的能力。
任何想法?
谢谢!
Basically, I have some TextBoxes on the screen and a button that executes a command. Each TextBox is bound to a particular property that varies in type. For example, one TextBox is bound to a Double property. The beauty with WPF is that when a value that is not a Double is entered into the TextBox the TextBox is outlined in red. Great!
However, is there a way to detect when one of those TextBoxes is showing an illegal value?
Ultimately, I want to make the command that's bound to the button enabled or disabled based on the fact of one or more TextBoxes having the "illegal value" outline on them. I didn't know if there was a built-in way to do this with WPF. Sometimes I take the long route in doing something only to realize WPF already has the ability built-in.
Any ideas?
Thanks!
这篇关于检测TextBox是否包含无效数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!