Dreamine.UI.Wpf 1.0.1
Dreamine.UI.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
EnumToStringConverter.cs
이 파일의 문서화 페이지로 가기
1using System.Globalization;
2using System.Windows.Data;
3
5
14public class EnumToStringConverter : IValueConverter
15{
24 public bool IsUpper { get; set; }
73 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
74 {
75 return IsUpper ? value?.ToString()?.ToUpper()! : value?.ToString()!;
76 }
77
134 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
135 {
136 if (value is string str && Enum.IsDefined(targetType, str))
137 {
138 return Enum.Parse(targetType, str);
139 }
140 return Binding.DoNothing;
141 }
142}
object Convert(object value, Type targetType, object parameter, CultureInfo culture)
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)