Category / Section
How to raise the Filters Collections Changed event
1 min read
The Property changed event of the filter item will be raised whenever there is a change at checkbox of that filter Item at FilterPopup. Please refer the below code snippet which illustrate the same.
C#
public MainWindow() { InitializeComponent(); this.pivotGrid1.Loaded += new RoutedEventHandler(pivotGrid1_Loaded); } void pivotGrid1_Loaded(object sender, RoutedEventArgs e) { this.pivotGrid1.GroupingBar.RowHeaderArea.Drop += new DragEventHandler(RowHeaderArea_Drop); this.pivotGrid1.Filters.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Filters_CollectionChanged); this.pivotGrid1.GroupingBar.FilterPopup.Closed += new EventHandler(FilterPopup_Closed); } void RowHeaderArea_Drop(object sender, DragEventArgs e) { this.pivotGrid1.CollapseAllGroup(); } void Filters_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { foreach (var item in e.NewItems) { if ((item is FilterExpression) && (item as FilterExpression).Tag is FilterItemsCollection) { FilterItemsCollection filterList = (item as FilterExpression).Tag as FilterItemsCollection; filterList.AllFilterItem.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(AllFilterItem_PropertyChanged); for (int i = 0; i < filterList.Count; i++) filterList[i].PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(MainWindow_PropertyChanged); } } this.pivotGrid1.CollapseAllGroup(); } void MainWindow_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { //Execute when click on the check box of the items(including "All") exist at Filter Popup } void AllFilterItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { //Execute when click on the "All" item's checkbox exist at Filter Popup } void FilterPopup_Closed(object sender, EventArgs e) { this.pivotGrid1.CollapseAllGroup(); } }
Please use the FilterPopup.Closed event to perform the functions like collapse, collapse all , expand or expand all after each filtering, since these functionalities will close the popup once it done hence we could not proceed with the further operations like check/uncheck the filter item.
void pivotGrid1_Loaded(object sender, RoutedEventArgs e) { this.pivotGrid1.GroupingBar.RowHeaderArea.Drop += new DragEventHandler(RowHeaderArea_Drop); this.pivotGrid1.Filters.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Filters_CollectionChanged); this.pivotGrid1.GroupingBar.FilterPopup.Closed += new EventHandler(FilterPopup_Closed); } void FilterPopup_Closed(object sender, EventArgs e) { this.pivotGrid1.CollapseAllGroup(); }