문제

My Customer Model is as below. Customer Model contains validation attributes

CustomerModel.cs

[IsRequired()]
CustomerID - Int;
[IsRequired()]
CustomerName - String;

CustomerViewModel contains 2 properties as below 1. ObservableCollection of CustomerModel (This is bound Items Source of drop down list) 2. Property returns CustromerModel object as Selected Item (Bound to SelectedItem)

My Question: How can i provide ValidatesOnDataErrors=true for combo box?

Do i need to write validation attribute on CustomerModel property inside CustomerViewModel?

Please suggest...

도움이 되었습니까?

해결책

IDataErrorInfo is a type specific implementation of Validation (vs. instance specific). You would be better off using ValidationRules. This link should help on how to implement ValidationRules: http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validationrules.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top