c# - Wpf Data annotation validation required, when the textbox is first created then validation does not work until something is typed in -
I am using Verification with validation contact in my WPF xaml project, which then looks at data annotation. All this works very well, I get a red box around a texblock and gets a tooltip from a style. However, there are two things that I can not work in, when a user opens a view, which has an area that is necessary, then I want Texbox to be found immediately around a red box. Instead of receiving it, after typing by me and then removing some of the text in the taxbox, which is necessary, how do I validate when I started it? Here are some code:
protected zero valid data (object value, [CallerMemberName] string propertyName = "") {var reference = new verification console (this, blank, empty) {username = propertyName} ; Recognizer Validity (value, reference); } [Required (error message = error message. Description required)] [string string (60, error message = error message Description description 60)] public string description {get {return description; } Set {description = value; ValidateProperty (value); OnPropertyChanged (); }} And lieutenant; Text box x: name = "description textbox" text = "{binding select entity. Description, valid valid exception = true, updated source transistor = property changes}" />
So I want to redraw the description textbox by default because the text box is empty when the user creates a new statement.
My second question is about data annotation. I dottyal
Daniel
You can not validate the initial source value with exception-based verification because it is necessary to call the property setter. However, you can use a different verification system such as IDataErrorInfo
(apply the interface and set ValidatesOnDataErrors = True
to your bindings). This mechanism allows validation on initial source value.
If your app requires .NET 4.5, then you can optionally use INotifyDataErrorInfo
(w / ValidatesOnNotifyDataErrors = True)
On your binding).
Comments
Post a Comment