Questions tagged [idataerrorinfo]

Provides the functionality to offer custom error information that a user interface can bind to.

277 questions
45
votes
15 answers

WPF DataGrid validation errors not clearing

So I have a WPF DataGrid, which is bound to an ObservableCollection. The collection has validation on its members, through IDataErrorInfo. If I edit a cell in a way so as to be invalid, and then tab away from it before hitting enter, then come back…
s73v3r
  • 1,751
  • 2
  • 22
  • 48
27
votes
2 answers

How to use IDataErrorInfo.Error in a WPF program?

I have an object like that: public class Person : IDataErrorInfo { public string PersonName{get;set;} public int Age{get;set;} string IDataErrorInfo.this[string propertyName] { get { …
guogangj
  • 2,275
  • 3
  • 27
  • 44
24
votes
4 answers

IDataErrorInfo vs ValidationRule vs Exception

Can anyone tell me which is a better approach for Validation in WPF. Implementing IDataErrorInfo Creating ValidationRule Throwing Exceptions in terms of performance, memory leaks, code maintainability and re-use.
WPF User
  • 1,028
  • 1
  • 10
  • 9
23
votes
4 answers

How can I validate multiple properties when any of them changes?

I have two date fields: StartDate and EndDate. StartDate must be earlier than EndDate. If the user changes the StartDate to something greater than the EndDate, a red border appears around that DatePicker, and vise versa. If the user changes the 2nd…
Rachel
  • 130,264
  • 66
  • 304
  • 490
17
votes
3 answers

How to force validation errors update on View from ViewModel using IDataErrorInfo?

I have a MVVM-based Window with many controls, and my Model implements IDataErrorInfo. There is also a SaveCommand button, which performs validation by analysing Model.Error property. The view displays the default red border around controls with…
surfen
  • 4,644
  • 3
  • 34
  • 46
16
votes
2 answers

Issue with WPF validation(IDataErrorInfo) and tab focusing

I have a TextBox bound to a property of an object which implements IDataErrorInfo. I set up the Validation.ErrorTemplate of the TextBox, and it works fine. The problem is that I have these on a TabControl, and the validation template doesn't…
Teodor
  • 497
  • 1
  • 6
  • 20
16
votes
3 answers

Error template is displayed above other controls, when it should be hidden

I'm trying to implement validation in my WPF application using the IDataErrorInfo interface, and I've encountered a not-so-desirable situation. I have this template which is used when a control fails to validate
Adi Lester
  • 24,731
  • 12
  • 95
  • 110
15
votes
2 answers

Force IDataErrorInfo validation

I have two controls on some panel: textbox and combobox:
Witcher
  • 1,070
  • 2
  • 15
  • 38
13
votes
1 answer

Show Validation Error Template on Controls within a UserControl in WPF

How do you get the WPF error template to appear on a control within a UserControl in WPF? I have a UserControl containing two Labels, two TextBoxes, and a CheckBox. One of the TextBoxes represents the name of the entity and it is bound to a Name…
CoderDawson
  • 133
  • 1
  • 1
  • 4
13
votes
4 answers

IDataErrorInfo - Initially ignore the errors when view is first loaded

I am trying to validate my model class using IDataErrorInfo as given below. //Validators public string this[string propertyName] { get { string error = null; if (propertyName == "Name") { error = ValidateName(); …
Jatin
  • 4,023
  • 10
  • 60
  • 107
12
votes
4 answers

Using IDataErrorInfo in M-V-VM

If my domain objects implement IDataErrorInfo, and I am using M-V-VM, how do I propagate errors through the ViewModel into the View? If i was binding directly to the model, I would set the "ValidateOnExceptons" and "ValidateOnErrors" properties to…
Micah
  • 111,873
  • 86
  • 233
  • 325
10
votes
3 answers

How can I define a IDataErrorInfo Error Property for multiple BO properties

I'm starting to implement validation in my WPF project via the IDataErrorInfo interface. My business object contains multiple properties with validation info. How do I get a list of ALL the error messages associated with the object. My thought is…
Bob
  • 1,484
  • 5
  • 22
  • 44
9
votes
3 answers

Validation in WPF - Custom validation rule or IDataErrorInfo

As a new WPF programer I cant find the difference between two different way to validate user input: What are the pros and cons of writing custom validation rule against implementing IDataErrorInfo, and vice versa? WhenShould I prefer one over the…
ET.
  • 1,899
  • 2
  • 18
  • 28
9
votes
1 answer

What is the meaning of `public string this[string columnName]` When implementing IDataErrorInfo interface?

What is the meaning of public string this[string columnName] When implementing IDataErrorInfo interface? public string this[string columnName] { get { switch (columnName) { case…
Saeid
  • 691
  • 7
  • 26
9
votes
2 answers

How does the IDataErrorInfo interface work?

I'm currently looking into validation for my WPF app and seen the mention of IDataErrorInfo. However there are few guides to how to use it and worse there are none who explain how it works. On MSND.com site this is given: MSDN public class Person :…
Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
1
2 3
18 19