예제 #1
0
        public FilterViewModel(string header, FilterIndexes filterIndex, IEnumerable <object> entities, Func <object, string> captionFunc)
            : this(header, filterIndex)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities), @"entities cannot be null.");
            }
            if (captionFunc == null)
            {
                throw new ArgumentNullException(nameof(captionFunc), @"captionFunc cannot be null.");
            }

            FilterItemVmCollection = new ObservableCollection <FilterItemViewModel>(
                entities.Select(
                    e => {
                var item              = new FilterItemViewModel(e, captionFunc);
                item.PropertyChanged += OnFilterItemPropertyChanged;
                return(item);
            })
                );

            foreach (var filterItem in FilterItemVmCollection)
            {
                filterItem.IsChecked = true;
            }
        }
예제 #2
0
        public FilterViewModel(string header, FilterIndexes filterIndex, bool?isCheckedValue = null)
            : this(header, filterIndex)
        {
            var trueItem = new FilterItemViewModel(true, TRUE_CAPTION);

            trueItem.PropertyChanged += OnFilterItemPropertyChanged;

            var falseItem = new FilterItemViewModel(false, FALSE_CAPTION);

            falseItem.PropertyChanged += OnFilterItemPropertyChanged;

            FilterItemVmCollection = new ObservableCollection <FilterItemViewModel>(new [] { trueItem, falseItem });

            trueItem.IsChecked  = isCheckedValue ?? true;
            falseItem.IsChecked = !isCheckedValue ?? true;
        }