1

I've created a simple form in WPF. I have worked on ASP.NET previously, so I'm wondering if there are 'Validation Controls' in WPF that are similar to ASP.NET, or if I need to manually validate my fields.

Thanks.

lhan
  • 4,585
  • 11
  • 60
  • 105
Dinesh
  • 119
  • 8

2 Answers2

0

sure, you can easily do this. What you want is IDataErrorInfo interface.
here is an example.

Muad'Dib
  • 28,542
  • 5
  • 55
  • 68
0

If you are using Binding, here's a good post on Stackoverflow

Quickly, you want something like that :

<TextBox Text="{Binding Age, ValidatesOnDataErrors=True}" />

And then with DataAnnotations you specify your rules. Then you use the

string IDataErrorInfo.this[string columnName]

function to validate. I use that all accross my application.

Community
  • 1
  • 1
Philippe Lavoie
  • 2,583
  • 5
  • 25
  • 39