0
내용이 변경 될 때 ObservableCollection에 ValidationRule을 적용해야합니다. 규칙은 간단하게 체크 경우 collection.Count> 0ObservableCollection의 validationRule
뷰 모델 :
이private ObservableCollection<string> _items;
public ObservableCollection<string> Items
{
get { return _items; }
set { _items = value; OnPropertyChanged("Items"); }
}
가 일반보기 예 : 나는 validationRule를 얻이 수없는 것
<ListBox>
<ListBox.ItemsSource>
<Binding Path="Items" ValidatesOnDataErrors="True">
<Binding.ValidationRules>
<a:ValidationRule />
</Binding.ValidationRules>
</Binding>
</ListBox.ItemsSource>
</ListBox>
해고 할 때 내용이 변경됩니다. 나는 심지어 CollectionChanged를 듣고 BindingExpression과 ValidationRule에 직접 호출을 시도했지만 아직 결과를 얻지 못했다. 이벤트가 발생했지만 바인딩/규칙의 호출은 유효성 검사 시퀀스를 실행하지 않습니다.
//runs the validation, but it does not update the HasError property (appears to just run validation outside of the binding's context
collection.CollectionChanged += (sender, args) => myValidationRule.Validate(collection, CultureInfo.CurrentCulture);
//doesn't execute the validation rule.. works for regular bindings - just not ObservableCollection bindings
collection.CollectionChanged += (sender, args) => myBindingExpression.UpdateSource();