Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

PagedCollectionView.CanFilter Property

Silverlight

Gets a value that indicates whether this view supports filtering by way of the Filter property.

Namespace:  System.Windows.Data
Assembly:  System.Windows.Data (in System.Windows.Data.dll)

public bool CanFilter { get; }

Property Value

Type: System.Boolean
true in all cases.

Implements

ICollectionView.CanFilter

This implementation always returns true.

Typically, you use this property to test whether the view supports filtering before setting the Filter property.

The following code example demonstrates how to use the Filter property to remove completed tasks from a DataGrid display. The filter is applied when a CheckBox is Checked, and removed when the CheckBox is Unchecked. This example is part of a larger example available in the How to: Group, Sort, and Filter Data in the DataGrid Control topic.


private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
    PagedCollectionView pcv = this.dataGrid1.ItemsSource as PagedCollectionView;
    if (pcv != null && pcv.CanFilter == true)
    {
        // Apply the filter.
        pcv.Filter = new Predicate<object>(FilterCompletedTasks);
    }
}

private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
    PagedCollectionView pcv = this.dataGrid1.ItemsSource as PagedCollectionView;
    if (pcv != null)
    {
        // Remove the filter.
        pcv.Filter = null;
    }
}

public bool FilterCompletedTasks(object t)
{
    Task task = t as Task;
    return (task.Complete == false);
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft