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 8642771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:51:48+00:00 2026-06-12T11:51:48+00:00

I have a ListView that is bounded to a CollectionViewSource. I followed this article

  • 0

I have a ListView that is bounded to a CollectionViewSource. I followed this article (refered to by many) for multiple filtering: http://www.zagstudio.com/blog/456#.UG8r6E1lWLE

I have two checkboxes set up for testing that do nothing but add a filter. Whenever I click on either one first, the filter is added to the CollectionViewSource and it works. Then when I click on the opposite checkbox, instead of the other filter being added to the CollectionViewSource and both filters working, my listview goes blank (when it shouldnt based on the data, and this happens in either order of checking my checkboxes)

Here is the relevant code: (Background: this application deals with filtering “Orders” for shipping software)

Loading Orders:

public class Order
{
    public int index { get; set; }
    public string host { get; set; }
    public Int64 orderNumber { get; set; }
    public string batchStatus { get; set; }
    public string sku { get; set; }
    public int numItems { get; set; }
    public string orderSource { get; set; }
    public string sourceOrderNumber { get; set; }
    public DateTime orderDate { get; set; }
    public DateTime orderTime { get; set; }
    public int customerID { get; set; }
    public string shipMethod { get; set; }
    public string billingState { get; set; }
    public bool statusChanged { get; set; }
    public int numSkus { get; set; }
    public string marketName { get; set; }
    public float weight { get; set; }
}

public class Orders : ObservableCollection<Order>
{
    public Orders()
    {
        SqlDataReader reader1 = cmd.ExecuteReader();
        while (reader1.Read())
        {
            Order order = new Order();

            order.host = (string)safeGetString(reader1, 0);
            order.orderNumber = (Int64)reader1["OrderNumber"];
            order.batchStatus = (string)safeGetString(reader1, 2);
            order.orderSource = (string)safeGetString(reader1, 3);
            order.sourceOrderNumber = safeGetString(reader1, 4);
            order.orderDate = (DateTime)reader1["OrderDate"];
            order.customerID = (int)reader1["CustomerID"];
            order.shipMethod = (string)safeGetString(reader1, 7);
            order.billingState = (string)safeGetString(reader1, 8);
            order.numItems = (int)reader1["NumItems"];
            order.numSkus = (int)reader1["NumSKUs"];
            order.marketName = (string)safeGetString(reader1, 11);
            order.weight = (float)(double)reader1["ShippedWeight"];


            this.Add(order);
        }
        reader1.Close();
    }

Setting up CollectionViewSource:

cvs = (CollectionViewSource)(this.Resources["cvs"]);

Checkbox Functions: (Hardcoded “what to filter by” using filterString for testing)

public void checkBox2_Checked(object sender, RoutedEventArgs e)
    {
        filterString = "TX";
        cvs.Filter += new FilterEventHandler(billingStateFilter);
    }
    public void checkBox1_Checked(object sender, RoutedEventArgs e)
    {
        filterString = "Standard";
        cvs.Filter += new FilterEventHandler(shippingMethodFilter);
    }

And lastly, the filters:

private void shippingMethodFilter(object sender, FilterEventArgs e)
    {
        Order order = e.Item as Order;
        if ((order.shipMethod != filterString))
        {
            e.Accepted = false;
        }
    }

    public void billingStateFilter(object sender, FilterEventArgs e)
    {
        Order order = e.Item as Order;
        if ((order.billingState != filterString))
        {
            e.Accepted = false;
        }
    }

Like I said, the first filter always works. The second always makes the screen blank. Any ideas?

  • 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-12T11:51:49+00:00Added an answer on June 12, 2026 at 11:51 am

    You are re-using the filter string for both filters and once you check each box both filters will be applied. So if you:

    1. Check checkBox1, then filterString will be “Standard” and shippingMethodFilter will be hooked up.
    2. Check checkBox2, then filterString will be “TX” and billingStateFilter will be hooked up.

    At no point is shippingMethodFilter unhooked. So it will continue to filter based on a filterString of “TX”.

    You should probably add one filter method that checks to see if checkBox1/checkBox2 is checked and then optionally apply it’s filtering logic. Something like:

    private string shippingFilterString = "Shipping";
    private string billingFilterString = "TX";
    
    private void collFilter(object sender, FilterEventArgs e)
    {
        Order order = e.Item as Order;
        if (checkBox1.IsChecked == true && (order.shipMethod != shippingFilterString ))
            e.Accepted = false;
        if (checkBox2.IsChecked == true && (order.billingState != billingFilterString ))
            e.Accepted = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview that has multiple entries and each entry has 2 subitems.
I have a ListView that display Drawable s This is my code: @Override public
I have a ListView that is a View and this all the properties will
I have a ListView that is populated with 50 items. This is the xml
I have a ListView that displays comments for an article. Each comments has a
I have a ListView that contains two types of objects, single and multiple. The
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have ListView that uses a GridView to display several columns of data. Two
I have a ListView that shows around 300 items. When something is changed and
I have a listview that highlights a row when you mouseover it with the

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.