
I have the following implicit style:
<Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="Green" />
</Style>
However, only the foreground color changes - all font settings are ignored.
Searched this forum, I don't think it is Theme related, but I am using the Crystal theme
11 Answers, 1 is accepted
Thank you for the provided code snippet.
I have double check this on my side and the settings are applied to the cell. Attached to this reply you can find the project which I used to test your scenario. May I ask you to test it on your side, and let me know if I need to modify something in order to reproduce this behavior on my side.
Regards,
Dinko
Progress Telerik

Hi, I downloaded your project and it does indeed work - however it doesn't look like you are using the NOXAML versions of the controls. would that make a difference?
Thanks,
Eric
I have double check this on my side and the provided project reference NoXAML binaries. I have merged the required dictionaries in the App.xaml file. In the project, the Crystal theme is applied to the controls. Can you specify how you are merging the NoXAML assemblies in your main application?
Regards,
Dinko
Progress Telerik

Sure, in app.xaml:
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/System.Windows.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.Chart.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.Input.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.ConversationalUI.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.Data.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.DataVisualization.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.GridView.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.FileDialogs.xaml" />
<ResourceDictionary Source="/Telerik.Windows.Themes.Crystal;component/Themes/Telerik.Windows.Controls.ScheduleView.xaml" />
<ResourceDictionary Source="Assets/Styles.xaml" />

Hi Dinko,
As a test, I copied your keyed style into my window's resources. Same result - the foreground color changed. but the font and fontsize are unaffected
I tried to reproduce this by adding the same assemblies as you did on my side but still the font size and font are applied as expected. I will need to reproduce this behavior so I can further assist you with this. Would it be possible to modify the attached project to mimic your application implementation to reproduce this?
Regards,
Dinko
Progress Telerik


Hi Dinko,
I have more information. I realized that in my style.xaml file I also have this:
Style TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="TextTrimming" Value="None"/>
</Style>
If I change this, it changes the font used in the Grid. If I comment it out, then my implicit/explicit GridViewCell style can set FontFamily and FontSize.
This seems like a bug, since I should be able to have an implicit style for all my text boxes along with being able to individually style a grid cell.
Thanks again for your help
Thank you for the provided code snippet.
This is expected behavior by the framework. Basically, the GridViewCell style is targeting the element directly. The TextBlock inside the GridViewCell inherit these properties (FontFamily, FontSize etc.) from its parent which is GridViewCell. If you create an implicit style for TextBlock, this style will be applied to all TextBlock which does not have explicitly set Style property. This implicit style has a higher priority rather than inheritance. You can read more about this in this MSDN help article. More specifically you can navigate to the Dependency Property Setting Precedence List
section. What you could try is to explicitly set the Style property of every TextBlock to your custom style.
Regards,
Dinko
Progress Telerik

Hi.
I understand all of this.
However, with a TextBlock, while I may have an implicit style, on an individual textbox, I can override that style, either through an explicit style or by setting properties on the control itself. This does not appear to be possible with GridViewCells. Still looks like a bug to me
Another approach I can suggest is to define a separate implicit style in the Resources of the style for the GridViewCell like so:
<
Style
x:Key
=
"column1"
TargetType
=
"telerik:GridViewCell"
BasedOn
=
"{StaticResource GridViewCellStyle}"
>
<
Style.Resources
>
<
Style
TargetType
=
"TextBlock"
>
<
Setter
Property
=
"FontFamily"
Value
=
"Monospace"
/>
<
Setter
Property
=
"FontSize"
Value
=
"36"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Green"
/>
</
Style
>
</
Style.Resources
>
</
Style
>
<
Style
x:Key
=
"column2"
TargetType
=
"telerik:GridViewCell"
BasedOn
=
"{StaticResource GridViewCellStyle}"
>
<
Style.Resources
>
<
Style
TargetType
=
"TextBlock"
>
<
Setter
Property
=
"FontFamily"
Value
=
"Georgia"
/>
<
Setter
Property
=
"FontSize"
Value
=
"18"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Red"
/>
</
Style
>
</
Style.Resources
>
</
Style
>
This applies the text related properties of the cell as expected at my end whilst preserving the implicit style for the other TextBoxes.
Please try this out at your end as well and let me know if you find such an approach applicable.
Regards,
Dilyan Traykov
Progress Telerik