private void SearchTextBox_TextChanged(object sender, RoutedEventArgs e) { TextBox TB = (TextBox)sender; foreach (DataGridColumn DGC in this.Columns) { for (int ind = 0; ind < this.Items.Count; ind++) { FrameworkElement FE = DGC.GetCellContent(this.Items[ind]); if (FE != null && FE.GetType().Name == "TextBlock") { TextBlock TX = (TextBlock)FE; if (TX != null) { if (!string.IsNullOrEmpty(TB.Text) && TX.Text.ToUpper().Contains(TB.Text.ToUpper())) { System.Windows.Media.BrushConverter BC = new System.Windows.Media.BrushConverter(); TX.Background = this.SearchedValueBackGroundColor; //TX.Background = System.Windows.Media.Brushes.Orange; TX.Foreground = System.Windows.Media.Brushes.YellowGreen; } else { TX.Background = System.Windows.Media.Brushes.White; TX.Foreground = System.Windows.Media.Brushes.Black; } } } } } }