views:

351

answers:

1

Hi! I'm using the new PagedCollectionView as my ItemsSource.

I've bound the CollectionView to a DataGrid, and need the grid to only show values that passes my filter like this:

            var oc = new ObservableCollection<User>();
        var pc = new PagedCollectionView(oc);
        dataGrid.ItemsSource = pc;

Where User class implements INotifyPropertyChanged. I'm applying a filter like this:

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        pc.Filter += Include;
    }

    private bool Include(object obj)
    {
        return (obj as User).Name == filterText.Text;
    }

And it works. Problem is that if I update a user the filter result is not updated. If a clear and reapply the filter it works.

Of course I can call the Refresh() method on the PagedCollectionView, but I thought this was possible to do without refreshing the view manually.

What I need is a "live filtering" mechanism. Any idea on how to code?

Scenario is: A application for view live alarms on a system. Say a user has selected to view only rows with "Error" or "Warning" in column0 (that is my filter). When column0 in a row then changes from "Info" to "Warning" that row should be automagically visible (it passes the filter) without me calling Refresh().

Thanks Larsi

A: 

Couldn't you just use the AutoCompleteBox control in the Silverlight 3 SDK?

Jeff Wilcox
Hmmmm. not sure I understand how. I've updated the post with a scenario to clarify what I need
Larsi