Search code examples
c#.netwpfteleriktelerik-grid

How to change telerik WPF RadGridView column filtering view template


We are using telerik controls in our project. I want to change telerik Radgrid view's (For WPF) filtering view.

As of now it looks like this as shown below:

Telerik WPF RadGridView Column filtering view

And I want to change the text being show to actual color, so that it looks more realistic for the user to filter. Something like this:

Color to be shown in filtering view in place of text

How to get hold of the template of filtering view and inject the color rectangle there.


Solution

  • How to get hold of the template of filtering view and inject the color rectangle there.

    The ControlTemplate can be found in Telerik.Windows.Controls.GridView.xaml:

    <ControlTemplate x:Key="FilteringControlTemplate" TargetType="grid:FilteringControl">
    ...
    

    I customized the ItemTemplate (for the Office2013 theme) to achieve the following, which should give you an indication of what needs to be done. You could also have a look at the CustomFilterControl example.

    enter image description here

    <ListBox.ItemTemplate>
      <DataTemplate>
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>
          <CheckBox
            Content=""
            FontSize="13"
            Grid.Column="0"
            IsChecked="{Binding IsActive, Mode=TwoWay}"
            VerticalAlignment="Center"/>
          <Rectangle
            Fill="{Binding ConvertedValue, Converter={StaticResource DistinctValueConverter}}"
            Grid.Column="1"
            Height="16"
            Width="30" />
        </Grid>
      </DataTemplate>