Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to WPF. I want to Implement a Dynamic Search Form, this form will show a collection of certain object that I passed it through its constructor as follow
C#
CC_BLL.Customers_Collection CustColl = new CC_BLL.Customers_Collection(true);
HelperFrm CustHelp = new HelperFrm(CustColl);
CustHelp.Show(); 

and I set the columns to be Auto generated upon properties of every passed object.
I style my Column Header to have radio button to set the searchable Column in run-time with setting first column as default column for searching and get that column through the code behind
C#
string SelectedColumn4Search = "ID";
foreach (DataGridColumnHeader dgColHeader in App.FindVisualChildren<DataGridColumnHeader>(dtGrid_SearchableData))
  if ((bool)((RadioButton)dgColHeader.Template.FindName("GridRdButton", dgColHeader)).IsChecked)
    {
      SelectedColumn4Search = dgColHeader.Content.ToString();
      break;
    }

All I hope to do is to search in the selected column by text entered in Search Text box and filter rows to show only rows satisfied search criteria.
Screen Shot of Search Form[^]

What I have tried:

I tried to use ICollectionView as follow
System.ComponentModel.ICollectionView CV_Search = CollectionViewSource.GetDefaultView(dtGrid_SearchableData.ItemsSource);
but when try to filter it needs a StrongType item to filter on its property which It's passed in runtime & I dont know its type
Posted
Updated 28-Feb-16 1:13am
v2

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