WPF Metro design: how to apply a case with style?

I am trying to develop an interface in WPF following Metro design principles - see the Scott Barnes website for a great overview.
A character wrapper is one of the steps of Metro that can be easily achieved with css using the text-transform property.
How about managing WPF?
It would be useful to declare different styles for the menu, title, subtitles in the resource file and change the shell by simply editing the applied style.

Note:
[1] TextBox.CharacterCasing is not applied, it includes only manually entered characters.
[2] I cannot imagine a suitable value converter for this task.

+4
source share
1 answer

There are a couple of approaches to this. In each case, you may need all uppercase or lowercase characters. You can easily apply a ValueConverter that will apply logic and return a value.

A quick example of this type of implementation:

<converters:LowerCase x:Key="toLowerConverter"/> <ControlTemplate TargetType="CustomControlYouMade"> <HeaderedContentControl Header="{Binding RelativeSource={RelativeSource AncestorType={x:Type CustomControlYouMade}}, Path=Header, Converter={StaticResource toLowerConverter}}" /> </ControlTemplate> 

And the logic of the converter:

 public sealed class LowerCase : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var str = value as string; return string.IsNullOrEmpty(str) ? string.Empty : str.ToLower(); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {} } 

For advanced typography options such as ligatures, indexes / superscripts, intercepts, etc., you will need a compatible OpenType font. See the MSDN Article for what is possible.

0
source

Source: https://habr.com/ru/post/1344294/


All Articles