Dreamine.UI.Wpf 1.0.1
Dreamine.UI.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
EnumToVisibilityConverter.cs
이 파일의 문서화 페이지로 가기
1using System.Globalization;
2using System.Windows;
3using System.Windows.Data;
4
6
15public class EnumToVisibilityConverter : IValueConverter
16{
25 public bool IsInverse { get; set; }
26
75 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
76 {
77 if (value == null || parameter == null)
78 return Visibility.Collapsed;
79
80 string enumValue = value.ToString() ?? string.Empty;
81 string[] targetValues = parameter.ToString()?
82 .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
83
84 bool result = targetValues.Contains(enumValue, StringComparer.OrdinalIgnoreCase)
85 ? true
86 : false;
87
88 result = IsInverse ? !result : result;
89
90 return result ? Visibility.Visible : Visibility.Collapsed;
91 }
92
140 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
141 {
142 return Binding.DoNothing;
143 }
144}
object Convert(object value, Type targetType, object parameter, CultureInfo culture)
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)