2010-11-18 81 views
0

大家好我對WPF很新,並嘗試一些示例 程序來了解它。WPF:提交按鈕的數據驗證

我有一個應用程序有以下字段

Username(TextBox) 

    Password(PasswordBox) 

    Button(Submit) 

要求:

我要做的用戶名和密碼的數據驗證。

1.Validation when the cursor moves from the Box. 

2.Validation when the Submit is pressed. 

爲了實現這兩個觸發器需要被使用。 以及如何獲得我的第二個要求的代碼。

如果您可以分享任何示例代碼或直接給我一些 鏈接,這將是非常有益的。

+0

請看這裏http://stackoverflow.com/questions/4574304/wpf-validation-how-to-show-tooltips-and-disable-run-button – 2012-01-23 16:47:04

回答

1

您需要查看使用IDataErrorInfo接口。

但是,我肯定會推薦首先查看MVVM。有建幫你無數的框架:

好資源: