Click here to Skip to main content
15,886,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to either paginate or filter the datagris seperately, but it seems like I cannot do both at the same time?

C#
ObservableCollection<LotTracing> items = new ObservableCollection<LotTracing>();

       ICollectionView SourceCollection;
       public LotSearchUI()
       {
           InitializeComponent();
           items = sourceCollection;
           SourceCollection = CollectionViewSource.GetDefaultView(items);
           this.DataContext = this.SourceCollection;
           dataGrid1.ItemsSource = this.SourceCollection;

           foreach (var prop in typeof(LotTracing).GetProperties())
               comboBoxCategory.Items.Add(prop.Name.ToString());
       }


and then I have a filter on searchbox textchanged ..

private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    this.SourceCollection.Filter = item =>
    {
        LotTracing vitem = item as LotTracing;
        if (vitem == null) return false;

        PropertyInfo info = item.GetType().GetProperty(comboBoxCategory.Text);
        if (info == null) return false;

        return info.GetValue(vitem, null).ToString().Contains(SearchTextBox.Text);

    };
}


What I have tried:

I have tried adding in the PagingCollectionView : CollectionView Samplle that is floating around but it doesn't respond to the filter. I see this being asked alot, but the answers all reference a site that is no longer active.
Posted
Updated 14-Jun-22 21:14pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900