Dreamine.UI.Wpf 1.0.1
Dreamine.UI.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
SelectedItemsCountRangeConverter.cs
이 파일의 문서화 페이지로 가기
1using System.Collections;
2using System.Globalization;
3using System.Windows.Data;
4
6
15public class SelectedItemsCountRangeConverter : IValueConverter
16{
73 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
74 {
75 var count = value is ICollection collection ? collection.Count : 0;
76
77 if (parameter is string paramString && !string.IsNullOrEmpty(paramString))
78 {
79 bool bCheck = false;
80
81 var parts = paramString.Split('-');
82 if (int.TryParse(parts[0], out int min))
83 {
84 bCheck = count >= min;
85 }
86 if (parts.Length == 2 && int.TryParse(parts[1], out int max))
87 {
88 bCheck = bCheck && count <= max;
89 }
90
91 return bCheck;
92 }
93
94 return false;
95 }
96
145 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
146 => Binding.DoNothing;
147}
object Convert(object value, Type targetType, object parameter, CultureInfo culture)
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)