-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.cs
37 lines (33 loc) · 1.18 KB
/
MainViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using DevExpress.Mvvm;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace ValidationErrorHostBehavior.ViewModels {
public class MainViewModel : ViewModelBase, IDataErrorInfo {
protected string firstname_;
[Required]
[RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$",
ErrorMessage = "Characters are not allowed.")]
public string FirstName {
get { return this.firstname_; }
set { this.SetProperty(ref this.firstname_, value, "FirstName"); }
}
protected string lastname_;
[Required]
[RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$",
ErrorMessage = "Characters are not allowed.")]
public string LastName {
get { return this.lastname_; }
set { this.SetProperty(ref this.lastname_, value, "LastName"); }
}
public string Error {
get {
return string.Join(";", this["FirstName"], this["LastName"]);
}
}
public string this[string columnName] {
get {
return IDataErrorInfoHelper.GetErrorText(this, columnName);
}
}
}
}