C# WPF Datagrid Filter List


I have a WPF application that contains two datagrids. I have a object of type OrderBlocks which contains one list of type Orders, please see below.

class OrderBlocks
   public string setting;
   public List<Order> Orders;

class Order
  public double Amount;
  public int Name;
  public bool Status;

Open in new window

What I would like is both of my datagrids to be bound to my list Orders. However I want one datagrid to show all orders in my list where the Status is true and the other grid to show all the orders where the status is false.

Also what I would like is if the user changes the status in one of the datagrids that the Order then moves to the other datagrid.

The link here
Example Solution shows a solution where ListCollectionView is subclassed. This sounds like a good example for me to follow, however I do not know how to go about this.

Just to mention that my list when bound to the datagrids will not add any new Orders and also the no Orders can be deleted.

Any help would be great.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gautham JanardhanCommented:
var active = new CollectionViewSource();
            active.Source = orders;
            active.Filter += (a, e) => { return ((Order)e.Item).Status; };

            var inActive = new CollectionViewSource();
            inActive.Source = orders;
            inActive.Filter += (a, e) => { return !((Order)e.Item).Status; };

Open in new window

and then bind active and inactive to grids as itemssource

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.