c# - Validation.GetHasError always return true for WPF ValidationRule -
I saw a good solution to check the validity of the group of contrÃ'ls:
In my window. Xaml.cs: My problem is, in my case, even if I get an error, then the VID is always right back. I think a xaml mistake The reason is ... but? My windows XAM is: And here my class is C:: Do you know why the validity is always correct? Thanks a lot :) The best regard is :) I think the problem is All the truths will return if the source specifies each element of the sequence The predicate, passes the test in or if the sequence is empty ; Otherwise, wrong.
Private bool ISValid (Dependency Object OBJE) {// dependency object is valid if there is no error in it, // and all your children (which are dependent items ) Are error-free! Validation Gethas Error (OBJ) & amp; Amp; LogicalTreeHelper.GetChildren (obj). OFTIP & lt; DependencyObject & gt; (). All (Children => IsValid (Children)); }
& lt; window. Resources & gt; & Lt; Commandbinding X: key = "binding" command = "save" execution = "save save" CanExecute = "Save_CanExecute" /> & Lt; /Window.Resources> & Lt; Text box name = "Type textbox" grid. Column = "1" vertical alignment = "center" height = "20" & gt; & Lt; TextBox.Text & gt; & Lt; Binding Path = "Styvert Type" & gt; & Lt; Binding.ValidationRules & gt; & Lt; Exceptional Rule / & gt; & Lt; /Binding.ValidationRules> & Lt; / Binding & gt; & Lt; /TextBox.Text> & Lt; / Text box & gt; & Lt; Button template = "{static resource boton reso test}" command = "save" & gt; & Lt; Button.CommandBinding & gt; & Lt; Static Resource Resources = "Binding" & gt; & Lt; / Static Resources & gt; & Lt; /Button.CommandBindings> & Lt; Image Source = "toolbar_wallassar png" height = "16" /> & Lt; / Button & gt;
Private string m_strEvtType; Public string strEvtType {get {return m_strEvtType; } Set {m_strEvtType = value; If (m_objEvtCode.ReadEvtTypebyType (m_strEvtType)! = 0) {New ApplicationExation (M_StrevetTipTRIM) + "lies!"); } FirePropertyChangedEvent ("strEvtType"); FirePropertyChangedEvent ("m_objEvtCode.strDes"); }}
all use in your
Linq
return! To check Validation.GetHasError (obj), try using other Linq method like
Any . ) And amp; Amp; ! LogicalTreeHelper.GetChildren (obj). OFTIP & lt; DependencyObject & gt; (). Any (child => IsValid (child));
Comments
Post a Comment