public CFilterControl(Popup pppParent, enFilterTarget filterTarget, List <FilterPredicate> predicates, FilterControlCommandHandler FilterCommandFunc, FilterControlCommandHandler CancelCommandFunc) { InitializeComponent(); ParentPopup = pppParent; FilterTarget = filterTarget; CloseReason = enCloseReason.LostFocus; m_FilterPredicatesOnOpen = new List <FilterPredicate>(); foreach (FilterPredicate predicate in predicates) { FilterPredicate NewPredicate = new FilterPredicate(predicate); NewPredicate.PropertyChanged += Predicate_PropertyChanged; FilterPredicates.Add(NewPredicate); m_FilterPredicatesOnOpen.Add(new FilterPredicate(predicate)); } CancelCommand = new CCommand(() => { CloseReason = enCloseReason.Cancel; CancelCommandFunc(this); }); FilterCommand = new CCommand(() => { CloseReason = enCloseReason.OK; FilterCommandFunc(this); }); Predicate_PropertyChanged(this, null); }
private void Predicate_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (FilterPredicates.All(arg => arg.IsSelected)) { // Все элементы выбраны chkSelectAll.IsChecked = true; } else if (FilterPredicates.All(arg => !arg.IsSelected)) { // Все элементы не выбраны chkSelectAll.IsChecked = false; } else { // Что-то выбрано, а что-то нет chkSelectAll.IsChecked = null; } FilterCommand.CanExecute = FilterPredicates.Count > 0 && (chkSelectAll.IsChecked == null || chkSelectAll.IsChecked.Value); }