I'm trying to develop a UI in WPF following Metro design principles - see Scott Barnes website for a gr开发者_开发知识库eat survey.
Character casing is one of Metro milestone, which can be easily achieved in css using text-transform property. What about WPF control? It would be useful to declare various style for menu, title, subtitle in a resource file, and modify casing by simply editing the applied style.Note:
[1] TextBox.CharacterCasing doesn't apply, it involves only manually entered characters. [2] I can't imagine an appropriate value converter for this task.There are a couple approaches to this. On a per-case basis you may want all upper or lower case characters. You can easily apply a ValueConverter which will apply logic and return a value.
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 converter logic:
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 like ligatures, subscript/superscript, swashes, etcetera., you'll need a compatible OpenType font. See this MSDN article to see what's possible.
精彩评论