Search code examples
wpfxamldatatrigger

datagrid column custom check mark


I want a read only column bound to a boolean that shows a check mark image when true and nothing when false.

The problem is the false value; I just want to show whatever the background of the datagrid is, but I don't see how to clear the image source.

What should the Value of the image source be to do this?

Cheers,
Berryl

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <Image Name="imgChecked" Source="\Img_Checkmark" />
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsPrimary}" Value="False">
                <Setter TargetName="imgChecked" Property="Source" Value=""/> *** ??? ***
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

Solution

  • Rather use Visbility Property

    <DataTrigger Binding="{Binding IsPrimary}" Value="False">
        <Setter TargetName="imgChecked" Property="Visibility" Value="Hidden"/>
    </DataTrigger>
    

    The Value for Source would be "{x:Null}"