Restyle/Recolor Border of (Focused) Cell

2 posts, 0 answers
  1. Barry
    Barry avatar
    3 posts
    Member since:
    Jan 2017

    Posted 27 Nov Link to this post

    In a RadGridView, I am trying to change the border around the cell which has focus. Currently it appears as a faint grayish color, my boss has asked that I make it a darker, thicker border. Not having any luck so far. Why won't the Style definition below work?

     

    <telerik:RadGridView.Resources>

                    <Style TargetType="telerik:GridViewCell">

                        <Style.Triggers>

                            <Trigger Property="IsCurrent" Value="True">

                                <Setter Property="BorderBrush" Value="#000000" />

                                <Setter Property="BorderThickness" Value="2" />

                            </Trigger>

                        </Style.Triggers>    

                    </Style>

    </telerik:RadGridView.Resources>

  2. Martin
    Admin
    Martin avatar
    108 posts

    Posted 30 Nov Link to this post

    Hi,

    This approach does not work for several reasons - the border thickness is bound and converted based on setters from the RadGridView and the VerticalGridLinesWidth. Furthermore, the current state of the grid view cell is set via a multitrigger for IsCurrent = true and IsInEditMode = false (in the WPF-only themes - Green, Office2016/Touch, Material) and via a VisualState x:Name="Current" (in the rest of the themes), in which a visual element in the template of the cell is shown/hidden. So in order to modify the visual appearance of the GridViewCell in the IsCurrent state, you can extract the control template for the cell and edit the setters of the Background_Current Border in it. In my opinion, it is cleaner and easier to copy the style from the generated resource dictionaries in the Themes.Implicit folder from the installation to be sure that it is properly extracted, rather than relying on the VS designer as there are some issues with the process that we are aware of and had reported to Microsoft. The same approach could be used to modify other states of the GridViewCell, such as IsMouseOver, IsSelected, is in edit mode, ect.

    I hope that you help you in implementing a custom look for the GridViewCell. If you have any other queries, please do not hesitate to contact us further.

    Regards,
    Martin
    Progress Telerik
    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