Reputation: 178
I am working on XamGrid using MVVM architectural style while removing the filter using the below code, the filter get removed but the filter cell still contains the filter value which should be empty.
foreach (var columnBase in dataGrid.FilteringSettings.RowFiltersCollection)
{
var col = (RowsFilter)columnBase;
col.Column.FilterColumnSettings.FilterCellValue = string.Empty;
}
dataGrid.FilteringSettings.RowFiltersCollection.Clear();
Upvotes: 1
Views: 347
Reputation: 178
After long analysis find that you will find such code at many places but the most important thing is your FilterScope which should be set to ColumnLayout i.e
dataGrid.FilteringSettings.FilteringScope = FilteringScope.ColumnLayout;
RowFiltersCollection rfc = dataGrid.FilteringSettings.RowFiltersCollection;
if (rfc != null)
{
foreach (RowsFilter RF in rfc)
{
if (RF.Conditions.Count != 0)
RF.Conditions.Clear();
}
}
dataGrid.FilteringSettings.RowFiltersCollection.Clear();
Upvotes: 0