views:

18

answers:

1

Hi,

Let's say I have a WPF application that shows "questions". Questions can have different statuses, such as "open", and "answered". The questions are stored in an ObservableCollection and displayed on a DataGrid.

I want to have a toggle button at the top that switches between "open" and "answered" questions. When a user clicks the "open" button, the grid should display only open questions, and when a user clicks the "answered" button, it should display only answered questions.

These objects are constantly being updated by another thread (every second). In addition, their status can be changed from another thread, and the grid would need to be updated.

What is a good way to filter on this collection? Right now I am using ICollectionView and calling Refresh() when a question's status changes, but I am getting errors due to calling refresh while "AddItem/EditItem" transaction occurring.

Thanks.

A: 

I would suggest that you just lock the calls to Refresh and the adding & editing of items to prevent the two threads conflicting and causing the errors

Steve Greatrex
Looks like it works, thanks!
thefactor