Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1285
Boolean column to Image
posted

I been searching but still can't find a clear solution to my requirment.

I would like to use a style and triggers to determine image. Style below.

I don't know what property to bind my trigger. I could do DataItem.PropertyInClass but then I will need a style for each property that will need to use the style. Is there a way that I can say current column, in other words the data row & column that needs to be stylized that way I have one style.

Thanks

 <Style x:Key="BoolCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                    <Image x:Name="BoolImg" Source="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center"
                           Width="16px" Height="16px" Margin="5"/>

                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=?????}" Value="True">
                            <Setter TargetName="BoolImg" Property="Source" Value="/CAPPS;component/Resources/16px/check2.png" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=??????}" Value="False">
                            <Setter TargetName="BoolImg" Property="Source" Value="/CAPPS;component/Resources/16px/delete2.png" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Parents
  • 138253
    Verified Answer
    Offline posted

    Hello boricua,

    Thank you for your post. I have been looking through it and after some researches I found out that your Binding should look like this:

    Binding="{Binding RelativeSource={RelativeSource Self},Path=Value}"

    By doing this the DataTrigger will check every cell’s value and if it is True or False the corresponding Setter will be applied. Please let me know if this helps you or I have misunderstood you in any way.

    Looking forward for your reply.

Reply Children
No Data