데이터 폼에 데이터 폼과 데이터 격자가 있습니다. 이 DataGrid는 ObservableCollection에 바인딩됩니다. 관측 가능한 컬렉션의 개수가 0 일 때 ValidationException을 throw하는 CustomValidator를 작성했습니다. ValidationSummary 컨트롤은이 예외를 처리하지 않고 대신 응용 프로그램이 불안정 해지고 Application Unhandled Exception을 호출합니다. RIA 서비스를 사용하지 않습니다. 아래 코드는Silverlight ValidationSummary 처리 안 함 ValidationException
public class UserCompanyProgram : INotifyPropertyChanged
{
public void ToWebServiceProgram()
{
lstUserProgram.CollectionChanged += (sender, e) =>
{
//Validator.ValidateProperty(lstUserProgram,
// new ValidationContext(this, null, null) { MemberName = "lstUserProgram" });
lstUserProgram = _lstUserProgram;
UserProgramChanged();
};
}
private ObservableCollection<Pricing.Model.UserProgram> _lstUserProgram = new ObservableCollection<UserProgram>();
[CustomValidation(typeof(ModelValidator), "ValidateUserProgramCollection")]
[Display(Name = "New Programs", Description = "Add program")]
public ObservableCollection<UserProgram> lstUserProgram
{
get { return _lstUserProgram; }
set
{
Validator.ValidateProperty(lstUserProgram,
new ValidationContext(this, null, null) { MemberName = "lstUserProgram" });
this._lstUserProgram = value;
NotifyPropertyChanged("lstUserProgram");
}
}
}
dgSelectedPrograms.SetBinding(DataGrid.ItemsSourceProperty, new Binding("lstUserProgram") { ValidatesOnNotifyDataErrors=true, ValidatesOnExceptions=true });
어떻게 ValidationSummary에서 예외를 처리합니까?