Hi,
in 2018.2.515.45 version of telerik RadGridView I did:
var col =
new
GridViewDataColumn() { DataMemberBinding =
new
Binding(item.Name), Header = header };
col.CellStyle =
new
Style();
col.CellStyle.Setters.Add(
new
Setter(GridViewCell.FontWeightProperty, FontWeights.Bold));
MyRadGridView.Columns.Add(col);
to set the font of a certain column to bold. Now, after update to 2020.1.115.45 version this is not working any more. The content of this column is invisible.
I tried this:
col.CellStyle =
new
Style() { TargetType =
typeof
(GridViewCell) };
but no changes.
How can I add a setter to the style in new version?
BR Gert
4 Answers, 1 is accepted
Hello,
I have tested your scenario on my end with our Office Black theme and it looks like it works as expected. Can you please send us a sample project showing your setup?
If this is not possible please let us know which is the theme and the theming mechanism you use in your application (StyleManager or implicit themes).
As you are saying that the content is invisible, I would suggest that you are using StyleManager, but with the upgrade the binaries became NoXAML (which requires implicit styling) which will lead to disappearing of the cells when using a custom style without basing it on ours (GridViewCellStyle in your case). Can you check the binaries as well?
Thank you for your cooperation.
Sia
Progress Telerik
Hi Sia,
we are using implicit styles with NoXAML dll approach and theme = "Office2016".
I try to set the style in the DataContextChanged event of the hosting window, wich was always working:
foreach
(var item
in
dc.Data.First().GetType().GetProperties().Where(Q => Q.CustomAttributes.Any(q => q.AttributeType.Name ==
"MainCol"
|| q.AttributeType.Name ==
"VisibleCol"
)))
{
var atr = item.CustomAttributes.FirstOrDefault();
string
header = dc.GetLocalizationByName(atr.ConstructorArguments.First().Value.ToString());
var col =
new
GridViewDataColumn() { DataMemberBinding =
new
Binding(item.Name), Header = header };
if
(atr.AttributeType.Name ==
"MainCol"
)
{
col.CellStyle =
new
Style();
col.CellStyle.Setters.Add(
new
Setter(GridViewCell.FontWeightProperty, FontWeights.Bold));
}
LOVGrid.Columns.Add(col);
}
pic MainColumn
Thanks for helping me!
Gert
Hello Gert,
I have reviewed again the code that you have sent and I do not see basing your style on the default one. This is very important because otherwise GridView cells lost their template. That is why the content of the column is invisible. Please check the attached project. This is where I base the style on ours:
Style newStyle = new Style(baseStyle.TargetType, baseStyle);
If it does not help, please modify the project in a way I can see your exact scenario.
Regards,
Sia
Progress Telerik
Hi Sia,
the line
Style baseStyle = Application.Current.Resources[
"GridViewCellStyle"
]
as
Style;
was the missing hint.
Now it is working as expected, thank you very much!!
BR Gert