I'm using a datagrid bound to an observable collection(autogenerate columns mode).
I need to set all Column Filters to case insensetive mode(when user open filter of string column, case-sensetive mode will be off). I tryed to find it in documantation and here, but without any result. Please, can you help me.
Thanks a lot,
Petr
4 Answers, 1 is accepted
Hi Petr,
This available as a built-in option, just click the case-sensitive button in the Text filter UI. Here's a screenshot:
Custom Filter UI Control
If you want that turned on by default, you'll need to do the following:
- Disable automatic column generation (set AutoGenerateColumns="False")
- Manually define the columns for your DataGrid
- Create a custom FilterControl
- Assign that custom FilterControl to the column(s) that need it.
First, you'll want to carefully read the tutorial on how to use a custom FilterControl (specifically parts 3 and 4 will be what you'd be using). In your case, you can just extend our DataGridTextFilterControl and set the IsCaseSensitive to false:
public class MyPresetTextFilterControl : DataGridTextFilterControl { public MyPresetTextFilterControl() { IsCaseSensitive = false; } }
To be clear, you would be using MyPresetTextFilterControl instead of ColorFilterControl from the tutorial. To help clarify, I've done this custom work in the attached demo for your reference. The 2nd column uses the custom filter control.
Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik

Thank you very much for answer and help!
I was expecting solution for case with auto generating column. Disable auto generating is not convinient for my task.
But i realized that this option was not added and I can't use it in my case.
Anyway thank you for help!
Petr
Hello Petr,
We usually do have an event that fires when the DataGrid generates columns automatically. However, this hasn't been implemented in UWP's DataGrid yet. You could use the Columns.CollectionChanged event in a similar fashion, but I have a better idea.
I have just realized you might be happy with just disabling IsCaseSensitive for all the TextFilterControls in the DataGrid. You can accomplish this without using a custom "MyFilterControl" or the "ColumnMarker"attached property.
Let's edit the previous example I sent.
Updated Example
Step 1. Remove the columns and go back to AutoGenerateColumns=True (the default):
<grid:RadDataGrid x:Name="DataGrid"
ItemsSource="{Binding Employees}">
<grid:RadDataGrid.Commands>
<local:CustomFilterButtonTapCommand />
</grid:RadDataGrid.Commands>
</grid:RadDataGrid>
Step 2. Delete ColumnMarker and MyFilterControl classes
Step 3. Update the CustomFilterButtonTapCommand class to the following:
public class CustomFilterButtonTapCommand : DataGridCommand
{
public CustomFilterButtonTapCommand()
{
this.Id = CommandId.FilterButtonTap;
}
public override bool CanExecute(object parameter)
{
return true;
}
public override void Execute(object parameter)
{
var context = parameter as FilterButtonTapContext;
// If the column's 1st filter control is a TextFilterControl
if (context.FirstFilterControl is DataGridTextFilterControl textfilterControl1)
{
textfilterControl1.IsCaseSensitive = false;
}
// If the column's 2nd filter control is a TextFilterControl
if (context.SecondFilterControl is DataGridTextFilterControl textfilterControl2)
{
textfilterControl2.IsCaseSensitive = false;
}
this.Owner.CommandService.ExecuteDefaultCommand(CommandId.FilterButtonTap, context);
}
}
I have attached an updated version of the demo so you can see this at runtime:
Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik

Your solution is excellent! Thank you very much. It works for me.
Petr.