1

I know I've asked the exact same question here (Override default Boolean Filtering in GridView WPF, Apply Custom bool filter) BUT the result wasn't the one expected. In fact, the checkbox should be the "default" one from the DatagridView and not the "checkbox" item. They are not the same.

This code provide a checkbox item:

<telerik:GridViewDataColumn Header="Intégrée" UniqueName="Intégrée" DataMemberBinding="{Binding IsIntegree, Converter={StaticResource MyConverter}}" ShowDistinctFilters="True">
<telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
        <CheckBox IsChecked="{Binding IsIntegree, Mode=TwoWay}"/>
    </DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>

This one provide a checkbox from the GridViewDataColumn with "ThreeState". The view result aren't the same.

<telerik:GridViewDataColumn Header="Intégrée" DataMemberBinding="{Binding IsIntegree, Mode=OneWay}" ShowDistinctFilters="True"/>

In the code behind I did change the output inside the filter BUT there is no more Binding from the string value ("Vrai") to the booleans values in rows ("True"):

private void GridView_DistinctValuesLoading(object sender, GridViewDistinctValuesLoadingEventArgs e)
{
    var col = ((Telerik.Windows.Controls.RadGridView)sender).GetDistinctValues(e.Column, false);
    IEnumerable<string> enu = col.Cast<bool>().Select(t => t.ToString());
    ICollection<string> distinctValues = enu.ToList();
    distinctValues.Clear();
    distinctValues.Add("Vrai");
    distinctValues.Add("Faux");
    e.ItemsSource = distinctValues;
}

How can I bind the String value to the boolean value in rows to Filter my rows ?

3
  • What's the difference between the CheckBoxes?
    – mm8
    Commented Aug 25, 2017 at 9:36
  • The item "checkbox" has a "check" in it, I don't want it. The "default" from the dataGridView is completly filled with the software color. I'm posting the picture.
    – Benoît S
    Commented Aug 25, 2017 at 9:55
  • here is the result I need from datagridView : ibb.co/nrTynQ and not the "classic" checkbox
    – Benoît S
    Commented Aug 25, 2017 at 9:57

1 Answer 1

1

You can apply whatever Telerik theme you are using to the CheckBox:

<telerik:GridViewDataColumn Header="Intégrée" UniqueName="Intégrée" DataMemberBinding="{Binding IsIntegree, Converter={StaticResource MyConverter}}" ShowDistinctFilters="True">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding IsIntegree, Mode=TwoWay}">
                <CheckBox.Style>
                    <Style TargetType="CheckBox">
                        <Style.Resources>
                            <telerik:Windows8Theme x:Key="Theme" />
                        </Style.Resources>
                        <Setter Property="telerik:StyleManager.Theme" Value="{StaticResource Theme}"/>
                    </Style>
                </CheckBox.Style>
            </CheckBox>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
1
  • Thank you ! I didn't know it was Windows8 theme by default. That's why. I thought that it was the DataGridView who managed the "conversion" from boolean to checkbox.
    – Benoît S
    Commented Aug 25, 2017 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.