I'm trying to add a Thick Border around a certain column programmatically. I can change the Background
property using identical methods but the border property won't change in anyway.
if (eligibleProperties.Contains(column.Header.ToString()))
{
Setter s1 = new Setter(GridViewCell.BorderThicknessProperty, new Thickness(7));
Setter s2 = new Setter(BorderBrushProperty, Brushes.Black);
Style st = new Style(typeof(GridViewCell));
st.Setters.Add(s1);
st.Setters.Add(s2);
column.CellStyle = st;
}
Working code for Background change
if (eligibleProperties.Contains(column.Header.ToString()))
{
Setter s2 = new Setter(BackgroundProperty, Brushes.Black);
Style st = new Style(typeof(GridViewCell));
st.Setters.Add(s2);
column.CellStyle = st;
}
Because of the default template structure of a Telerik GridViewCell
, modifying the cell borders is actually more complicated than just setting the BorderThickness
and BorderBrush
properties.
You will need to modify the control template. Please refer to the following threads for more information about this.
How do I change border color in cell style selector: https://www.telerik.com/forums/how-do-i-change-border-color-in-cell-style-selector
Change the row border colour: https://www.telerik.com/forums/change-the-row-border-colour