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()); }
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); }; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)