I want all texts in TextBlock
, Label
, MenuItem.Header
to be displayed in upper case.
The strings are taken from a ResourceDictio
This does not strictly answer the question but does provide a trick to cause the same effect.
I believe many finding their way here are looking how to do this with a style. TextBlock is a bit tricky here because it is not a Control but a FrameworkElement and therefore you can not define a Template to do the trick.
The need to use all uppercase text is most likely for headings or something like that where use of Label is justified. My solution was:
<!-- Examples of CaseConverter can be found in other answers -->
<ControlTemplate x:Key="UppercaseLabelTemplate" TargetType="{x:Type Label}">
<TextBlock Text="{TemplateBinding Content, Converter={StaticResource CaseConverter}}" />
</ControlTemplate>
<Style x:Key="UppercaseHeadingStyle"
TargetType="{x:Type Label}">
<Setter Property="FontSize" Value="20" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Template" Value="{StaticResource UppercaseLabelTemplate}" />
</Style>
<!-- Usage: -->
<Label Content="Header" Style="{StaticResource UppercaseHeadingStyle}" />
Note that this does disable some of the default behavior of Label, and works only for text, so I would not define this as default (no one probably wants all labels uppercase anyway). And of course you must use Label instead of TextBlock when you need this style. Also I would not use this inside of other templates, but only strictly as a topic style.