我想在按下某个键时验证文本框中的文本。这里是最短的代码示例显示了我想要做的事:UpdateSourceTrigger不工作?
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox FontSize="15" HorizontalAlignment="Left" Name="txtEmail" VerticalAlignment="Top" Width="135"
Text="{Binding ValidationRules.EmailAddress, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Window>
“ValidationRules”类:
当我开始在文本框中键入,我不明白“设置”作为控制台输出,尽管我使用的是UpdateSourceTrigger=PropertyChanged
。我已经完成了我的研究,但我能找到的所有例子都是漫长而混乱的。如果你能指出我在验证过程中遇到的其他错误,我也会很感激,但如果可能,请尝试用简单的术语来解释,因为我是WPF的新手。
是在即时窗口,有什么错误? – alu 2013-02-11 23:53:26
你在哪里设置'DataContext'到'ValidationRules'类 – 2013-02-12 00:00:45