WPF (.net 3.5) ValidationRule, IDataErrorInfo

I am trying to figure out the best way to validate data entry, and I was looking at ValidationRule and IDataErrorInfo. I have a virtual machine and a model, and I want the user not to enter alpha char in several text fields bound to doubling (or ints).

I ran into three problems

1) When I use ValidationRule, the method returns "ValidationResult", but where does this happen? Is it stored as a property somewhere where?

2) If I am an IDataErrorInfo user and enter an alpha char, it is never called (this is if the numbers are entered) Is this expected? *

* (I thought maybe a value converter might help here, but I feel like mixing two separate concepts)

3) Indeed, I want to do a check at the end when the user clicks “Save” and checks all the values. Therefore, perhaps the use of these two methods is not what I need for 1838300 . Is it right, this is really just for checking on the fly?

My thought about point 3 was that if the result of the ValidationRule was somewhere in the store, I could check this for each control or when it is ever stored. Or, if IDataErrorInfo was called, I could manually save some Boolean for each control and check them.

Any thoughts or ideas?

Thank!

+3
source share
2 answers

, :

dependency - , .

. , ints/doubles -, , ( TextBox Text) - .

, . . , , Validation IDataErrorInfo: .

+1

BookLibrary WPF Application Framework (WAF). , WPF "", .

0

Source: https://habr.com/ru/post/1751788/


All Articles