wpf - problems with validation rule -
I am trying to get a verification rule to return an error. I have implemented IDataErrorInfo in my model, which includes messages to return to my business object property and event validation. I have also created a validation rule. The problem is that there is no error in the IDataErrorInfo context in the rule on the verification rule firing (it has been bookmarked), even if the IDataErrorInfo implementation of my model generates one, the datagrid definitely shows that there was a verification failure.
I tested the rules and models by returning two separate messages, and the model's version always comes back. This is not the same as my rule, which is in the EternatorAffluent Object, or it's just making a new example.
DataGrid:
& lt; DataGrid ItemsSource = "{Binding Path = ProjectExpenseItemsCollection}" auto generated column = "wrong" name = "dgProjectExpenseItems" RowStyle = "{StaticResource RowStyle}" SelectedItem = "{binding path = selected project expansions, mode = doubwo, UpdateSourceTrigger = PropertyChanged}" CanUserDeleteRows = "True" CanUserAddRows = "True" & gt; & Lt; DataGrid.RowValidationRules & gt; & Lt; Vr: RodeDataInfodisationRol Validation Phase = "Renewed Value" /> & Lt; /DataGrid.RowValidationRules> & Lt; DataGrid.Columns & gt; & Lt; DataGridTextColumn header = "item number" binding = "{binding item number, mode = doubles, update resource-trigger = property changes, valid endoder errors = true}" /> & Lt; /DataGrid.Columns> & Lt; / Data grid & gt; Validation rule: Object "Idea" is not meaningless, but idei.error always has a zero-length string ("")
Public Class RoudinFodification Rules: Validation Rules {Public Override ValidationModified Certified (Object Value, CultureInfo Culture Infos) {Binding Group Binding Group = (Binding Group) Value; IDataErrorInfo idei = bindingGroup.Items [0] as IDataErrorInfo; String error = (idei! = Null)? Idea. Error: zero; Return (string.IsNullOrEmpty (error))? Validation Valid Required: New verification result (false, error + ": verification rules"); }}
Model / Business item :
public class ProjectExpenseItemsBO: IDataErrorInfo, IEditableObject, INotifyPropertyChanged {public string ItemNumber {get ; Set; } Public ProjectExpenseItemsBO () {} // String Method Static Bull IstressingMissing (String Value) {Return String. ISANOALAct (Value) || Value.Trim () == String.Empty; } # Field IDataErrorInfo member public string error {receive {this [string IA]. }} Public string this [string propertyName] {{string result = string.Empty; If (propertyName == "ItemNumber") {if (IsStringMissing (this.ItemNumber)) {Results = "Item number can not be empty IDataError!"; }} Return result; }}
The example of the IDataErrorInfo object will be your ProjectExpenseItemsBO object by you The only probed error is the error, which you have implemented to return this [string.Empty]
, which will always return the string. Empty You probably want to either change all of the error properties in order to see all the errors in the object, or modify the RowDatInfodification rules through the property and get the error message through the indexer for each one.
You are receiving validation errors from the model because the ValidatesOnDataErrors have been set to true with your obligation for ItemNumber, so the outline will call the indexer from the property name ItemNumber and receive your error message.
Comments
Post a Comment