Dreamine.UI.Wpf 1.0.1
Dreamine.UI.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
PropertyPathValueConverter.cs
이 파일의 문서화 페이지로 가기
1using System.Globalization;
2using System.Reflection;
3using System.Windows.Data;
4
6
15public class PropertyPathValueConverter : IMultiValueConverter
16{
73 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
74 {
75 if (values == null || values.Length < 2 || values[0] == null || values[1] == null) return null!;
76 var item = values[0];
77 var propName = values[1]?.ToString();
78 if (string.IsNullOrWhiteSpace(propName)) return null!;
79 var prop = item.GetType().GetProperty(propName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
80 return prop?.GetValue(item)!;
81 }
82
131 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
132 {
133 return new object[] { Binding.DoNothing, Binding.DoNothing };
134 }
135}
136
145public class PropertyAccessorConverter : IMultiValueConverter
146{
203 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
204 {
205 if (values == null || values.Length < 2 || values[0] == null || values[1] == null) return null!;
206 var item = values[0];
207 var propName = values[1]?.ToString();
208 if (string.IsNullOrWhiteSpace(propName)) return null!;
209 var prop = item.GetType().GetProperty(propName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
210 return prop?.GetValue(item)!;
211 }
212
261 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
262 {
263 if (parameter is object[] p && p.Length >= 2) { }
264 return new object[] { Binding.DoNothing, Binding.DoNothing };
265 }
266}
object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)