Exemplo n.º 1
0
        //Since the ColumnFilterHeader control is defined in the headerStyle for the grid, we can only get a reference to it once it loads.  We
        //then we have to find the column that the ColumnFilterHeader is associated with.  We do this by comparing the Header
        //and HeaderContent for each column.
        private void ColumnFilterHeader_Loaded(object sender, RoutedEventArgs e)
        {
            var header = sender as ColumnFilterControl;

            if (!FilterHeaders.Any())
            {
                if (header != null)
                {
                    header.TxtFilter.Focus();
                }
            }
            FilterHeaders.Add(header);
            if (header != null && header.HeaderContent != null)
            {
                var column = Columns.FirstOrDefault(c => c.Header != null && c.Header.ToString() == header.HeaderContent.ToString());

                header.Column           = column;
                header.Grid             = this;
                header.PropertyChanged += header_PropertyChanged;
                if (FilterType != null)
                {
                    header.ResetFilterValues(CreateFilterColumnInfo(column));
                }
            }
        }
Exemplo n.º 2
0
        //Each time any ColumnFilterHeader values change.  We need to generate the new predicate for the PagedCollectionView
        private void header_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var view = ItemsSource as PagedCollectionView;
            Predicate <object> predicate = null;

            foreach (var filter in FilterHeaders.Where(x => x.HasPredicate))
            {
                predicate = predicate == null
                    ? filter.GeneratePredicate()
                    : predicate.And(filter.GeneratePredicate());
            }
            CommitEdit();
            if (view != null)
            {
                view.Filter = predicate;
            }
        }
Exemplo n.º 3
0
 public void FireFilter()
 {
     OnFilter(this, new FilterEvent {
         FiltersPredicate = FilterHeaders.Where(x => x.HasPredicate)
     });
 }