i want to filter my DataGrid with a RowFilter. The User should be able to choose his column by selecting a cell. Than he puts some Text in a TextBox and he can filter the DataGrid. I tried some things but they didnt work. Maybe i can get some help here :) I would be happy for every reply. Here is my code and the things i tried:
private void Filter_Click(object sender, RoutedEventArgs e)
{
DataView DV1 = DT1.DefaultView; // DT1 is my DataTable-Object
// DV1.RowFilter = "Column1 = '" + Filter.Text + "'"; This works fine
DV1.RowFilter = "'" + DataGrid1.CurrentCell.Column+ "' = '" + Filtern.Text + "'"; // When i try this it doesnt work
DataGrid1.ItemsSource = DV1;
}
i tried some other commands: DataGrid1.CurrentCell.Column.DisplayIndex or DataGrid1.CurrentCell.Column.Header or DataGrid1.CurrentColumn but i always get an Error. The Command gives me a 0. Maybe someone has an idea?