🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
DataGrid filters
This page was created by Hans.karlsen on 2022-04-21. Last edited by Wikiadmin on 2026-07-29.

You can let users filter the visible rows in a WPF DataGrid by column and clear every active column filter from code in the current view.

Use column filters in a WPF DataGrid

A DataGrid is the table-style control used to present ViewModel list data as rows and columns. In WPF, the DataGrid provides column filters that the end user can apply from the column headers. A filter limits which rows are shown in that grid.

For example, a user can filter an Orders grid on its Status column to show only rows matching the value they enter or select through the grid's filter UI. The filter affects the current DataGrid display.

Use DataGrid filters when users need to narrow down an already displayed list. For general list behavior, including selection and actions, see Documentation:Tables and Grids.

Clear all active filters

Call ClearAllDataGridFilters() on IWECPOFService to remove all active column filters from the DataGrid in the current view.

  1. Get the IWECPOFService from the Eco service provider.
  2. Call ClearAllDataGridFilters() when your view needs to return the grid to its unfiltered state.
public void ClearAllDataGridFilters()
{
   sp.GetEcoService<IWECPOFService>().ClearAllDataGridFilters();
}

For example, expose this code from a view command or action named Clear filters. When the user activates that action, all column filters applied in the current DataGrid are removed and the grid can again show the rows that its underlying list provides.

Choose the right filtering approach

DataGrid column filters are UI-level filtering for a displayed WPF grid. They are not a replacement for a search that selects data from persistent storage.

Need Use Example
Let a user temporarily narrow the rows shown in a WPF DataGrid DataGrid column filters A user filters the visible Orders grid by Status.
Return a filtered grid to its normal display IWECPOFService.ClearAllDataGridFilters() A Clear filters action removes filters on Status, Customer, and Date columns.
Search or filter large persistent result sets Seeker view criteria and OCL expressions Search Persons whose last name starts with the entered text before presenting results.

A Seeker view evaluates its criteria against persistent storage and is the appropriate design when the user must search a potentially large database result set. Do not rely on a displayed-grid filter when the requirement is to query all matching records in storage.

Platform notes

This page describes WPF DataGrid filters and the IWECPOFService clearing call. Grid filtering behavior is platform-specific.

See also