Cha*_*u A 3 c# wpf xaml textbox lowercase
我尝试在WPF中通过XAML将大写转换为小写,如下所示:
<TextBox Height="86" CharacterCasing="Upper"/>
Run Code Online (Sandbox Code Playgroud)
我想实现用同样的场景TextBlock,Label和Button.
我该怎么做?
您应该使用值转换器:
public class ToUpperValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var str = value as string;
return string.IsNullOrEmpty(str) ? string.Empty : str.ToUpper();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)