Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8632377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:20:38+00:00 2026-06-12T09:20:38+00:00

i want to filter wpf datagrid, and i do that in this way,i use

  • 0

i want to filter wpf datagrid, and i do that in this way,i use datagridcolumnsheader and put a textbox in headers and use them filter each column:

  private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        textSearch = (sender as TextBox).Text;
        CollectionViewSource.Filter += new FilterEventHandler(FilterEvent); 
    }

and

 private void FilterEvent(object sender, FilterEventArgs e)
    {
        if (propertyName == null)
            return;
        var a = e.Item.GetType().GetProperty("Name");
        if (a != null)
        {
            if (textSearch != "")
            {
                var s = a.GetValue(e.Item, null);
                if (s != null)
                    e.Accepted = s.ToString().Contains(textSearch);
                else
                    e.Accepted = false;
            }
            else
                e.Accepted = true;
        }
    }

it works fine for a column like id,but when i want to make filter on another column like name ,it filters the list just by name and dosen’t keep the past filter,for example if i filter the list by id=2 ,and then filter it by name=’a’ ,it just filters list by name=’a’!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:20:38+00:00Added an answer on June 12, 2026 at 9:20 am

    To apply multiple filters to a collection bound to a WPF DataGrid you should instantiate a CollectionViewSource object as a proxy between the view and the collection (this will also work with other collection controls). Doing so will allow you to subscribe multiple filter event handlers to it’s Filter event. Filters are applied in the order in which they are subscribed and can be removed by unsubscribing them.

    If you used the CollectionViewSource.GetDefaultView() static method in your codebehind or ViewModel, this will return an instance of an ICollectionView which will only support a single filter with a Filter property.

    Your can find an example with source code here http://www.codeproject.com/Articles/442498/Multi-filtered-WPF-DataGrid-with-MVVM

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to filter e-mail headers received on my Postfix mail receiving server. I
I want to filter my observable collection of viewmodel objects to the objects that
I want to filter a property within a range, but items that does not
I want to filter DFWP through asp:TextBox. Using Office Designer I added DFWP with
I Have a Silverlight WPF app that shows tabs of data in this case
I want to filter out all entries in my access logs that have a
I want to filter a list of entities that I am fetching from a
I have a BaseAdapter and want use filter it. Its filled with object (1).
I want to implement this in Silverlight. Combobox with an inline filter in the
I have an string like this:- $sa_position = state/Gold,International/Participant,School/Participant,School/Bronze,national/Bronze,School/Gold; And I want filter this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.