MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.28k stars 2.45k forks source link

ControlsHelper.ContentCharacterCasing not working for Label #3699

Closed Gerardo-Sista closed 4 years ago

Gerardo-Sista commented 4 years ago

Hello, in MahApps v2 if I set

<Label mah:ControlsHelper.ContentCharacterCasing="Upper" Content="{lng:Language Key=WarningsContent}" />

the casing of bound text remains the same as was set in the bound value (lowercase)

Is it normal?

For completeness on labels is applied this simple style in app.xaml:

   <!--LABEL STYLE-->
            <Style TargetType="{x:Type Label}" BasedOn="{StaticResource MahApps.Styles.Label}">
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="FontSize" Value="{StaticResource LabelFontSize}" />
                <Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Accent}" />
            </Style>

Thank you.

timunie commented 4 years ago

HI @Gerardo-Sista , currently using mah:ControlsHelper.ContentCharacterCasing="Upper" is not applicateable on Label. You can use mah:ContentControlEx or adjust your Style:

    <Style TargetType="{x:Type Label}">
        <Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Label.Text}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Label}">
                    <mah:ContentControlEx x:Name="PART_ContentPresenter"
                                          Padding="{TemplateBinding Padding}"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Content="{TemplateBinding Content}"
                                          ContentCharacterCasing="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(mah:ControlsHelper.ContentCharacterCasing)}"
                                          ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Happy coding Tim

Gerardo-Sista commented 4 years ago

Thank you for fixing @punker76 @timunie . As end user the name ControlsHelper suggests me that can be applied to all controls, so it feels natural to use is for label, textbox etc. etc.