Filter a collection in a PagedCollectionView I have a scenario wherein I have to filter a collection in a PagedCollectionView. 
The filter criteria are Name and status which are checkboxes with Enabled and Disabled labels. If Enabled is checked it should filter out the list with all enabled rules and vice-versa. I have given it a try, but I believe this isn't the best way of doing it.

     private PagedCollectionView _autoDepRuleList;
    public PagedCollectionView AutoDepRuleList
    {
        get
        {
            return this._autoDepRuleList;
        }
        set
        {
            this._autoDepRuleList = value;
            RaisePropertyChanged("AutoDepRuleList");
        }
    }        

    private bool _isEnabled;
    public bool IsEnabled
    {
        get
        {
            return this._isEnabled;
        }
        set
        {
            this._isEnabled = value;
            RaisePropertyChanged("IsEnabled");
        }
    }

    private bool _isDisabled;
    public bool IsDisabled
    {
        get
        {
            return this._isDisabled;
        }
        set
        {
            this._isDisabled = value;
            RaisePropertyChanged("IsDisabled");
        }
    }

    private string _name;
    public string Name
    {
        get
        {
            return this._name;
        }
        set
        {
            this._name = value;
            RaisePropertyChanged("Name");
        }
    }

     public void Search()
    {
        var tempList = new AutoDeploymentRuleList();
        var filterList = new AutoDeploymentRuleList();

        foreach (AutoDeploymentRule item in this.AutoDepRuleList)
        {
            tempList.Add(item);
        }
        if (IsEnabled &amp;&amp; IsDisabled)
        {
            foreach (var item in tempList)
            {
                filterList.Add(item);
            } 
        }
        else if (IsEnabled)
        {
            foreach (var item in tempList.Where(r =&gt; r.Status.Equals("Enabled")))
            {
                filterList.Add(item);
            } 
        }
        else if (IsDisabled)
        {
            foreach (var item in  tempList.Where(r =&gt; r.Status.Equals("Disabled")))
            {
                filterList.Add(item);
            }                
        }
        else
        {
            foreach (var item in tempList)
            {
                filterList.Add(item);
            } 
        }
    this.AutoDepRuleList = new PagedCollectionView(filterList.Where(r =&gt; r.Name.ToLower().Contains(this.Name.ToLower())));


Now the idea is to do away with the above block and go for the below logic. I did it for the Name property, but I'm not sure how I can do it for the Status property which can be anything either Enabled or Disabled.

    this.AutoDepRuleList.Filter = new System.Predicate&lt;object&gt;(o =&gt;
    {
        AutoDeploymentRule rule = (AutoDeploymentRule)o;

        if (rule.Name.ToLower().IndexOf(this.Name.Trim().ToLower()) &gt;= 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    });          
}


How can I optimize it by removing those redundant where clauses and putting the entire thing under Predicate&lt;object&gt;?
If performance is your concern, won't boxing and unboxing the variable unnecessarily add an overhead? Why would you want to do that?

Wouldn't this be much easier?

this.AutoDepRuleList //if this is queryable/enumerable, or convert first
.Where(r =&gt; (isDisabled &amp;&amp; r.Status.Equals("Disabled")) || 
             (isEnabled &amp;&amp; r.Status.Equals("Enabled")) ||
              (!isDisabled &amp;&amp; !isEnabled))
//either ToList() if you just need to assign to another list, or ForEach if you want
//to iterate over list and do something
    .ForEach(filterList.Add);


Update: had forgotten the condition where both isDisabled and isEnabled were false.