Strikethrough/strikeout of whole row

9 posts, 1 answers
  1. jas
    jas avatar
    20 posts
    Member since:
    Jul 2006

    Posted 09 Mar 2010 Link to this post

    How can I apply a data-driven style to show a strikethrough (or strikeout) style to an entire row?

    Depending on a column value, I can succesfully apply font styling such as italic and colour (both font styles) but how to do strikethrough which is a text decoration?
  2. Answer
    Kalin Milanov
    Admin
    Kalin Milanov avatar
    447 posts

    Posted 12 Mar 2010 Link to this post

    Hello jas,

    If you want to strike through the text blocks you should be able to do it the same way you apply bold and italic. If you want however to strike through the whole row you can always dray a line on top of the row and show it when the row passes your conditions.

    Attached I am sending you a sample achieving the latter.

    Sincerely yours,
    Kalin Milanov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. jas
    jas avatar
    20 posts
    Member since:
    Jul 2006

    Posted 22 Mar 2010 Link to this post

    Thank you for such a complete answer!

    jas
  4. Markus Wolff
    Markus Wolff avatar
    18 posts
    Member since:
    Feb 2010

    Posted 22 Sep 2010 Link to this post

    Kalin, you mentioned TextDecorations may be applied the same way as FontStyles. I tried the following which works with Foreground and Background but not with TextDecorations, what am I missing? I'm currently using Rad Controls for WPF Version 2010.1.422.35

    This works:

    <Style TargetType="{x:Type telerik:GridViewCell}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsDeleted}" Value="True">
                <DataTrigger.Setters>
                    <Setter Property="Foreground" Value="Red" />
                </DataTrigger.Setters>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    This doesn't:

    <Style TargetType="{x:Type telerik:GridViewCell}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsDeleted}" Value="True">
                <DataTrigger.Setters>
                    <Setter Property="TextDecorations" Value="Strikethrough" />
                </DataTrigger.Setters>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    Any suggestions?
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 27 Sep 2010 Link to this post

    Hi Markus Wolff,

    The reason for the second style not to work is that GridViewCell does not have a TextDecorations Property.

    The workaround would be :

    Place a textblock inside the cell using the CellTemplate property. Target this textblock with the style .

    Let me know in case you have troubles/questions while  implementing this.

    Best wishes,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Chuck
    Chuck avatar
    2 posts
    Member since:
    May 2017

    Posted 17 May in reply to Pavel Pavlov Link to this post

    Could you please show an example of how that would work?  Thanks.
  7. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    603 posts

    Posted 22 May Link to this post

    Hello Chuck,

    Attached to my reply you will find a sample project that implements the approach suggested by my colleague with the current version of the controls. What I've done is to edit the control template of the GridViewRow element and introduce a rectangle inside, which is bound to a property of the underlying data object. I've then set this new style as the RowStyle of the respective RadGridView control.

    Do let me know whether such an approach would work for you.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  8. Chuck
    Chuck avatar
    2 posts
    Member since:
    May 2017

    Posted 23 May in reply to Dilyan Traykov Link to this post

    Dilyan,  thanks for the sample.  I was actually trying to achieve strikethrough of the individual text contents of each row cell, rather than drawing a line across the entire row.  Is there a way to apply a strikethrough text decoration of cell contents via a style?
  9. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    603 posts

    Posted 23 May Link to this post

    Hello Chuck,

    In such case, you can define the following style targeting the GridViewCell element:

    <Style BasedOn="{StaticResource GridViewCellStyle}" TargetType="telerik:GridViewCell">
        <Style.Resources>
            <Style TargetType="TextBlock">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=IsDeleted}" Value="True">
                        <DataTrigger.Setters>
                            <Setter Property="TextDecorations" Value="Strikethrough" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
    </Style>

    You can specify a key for this style and set it as the CellStyle for the columns you wish to apply it to.

    Do let me know if this provides the desired result.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top