markus / KCOM / Common / Converter / NullToCollapsedConverter.cs @ a8aec13a
이력 | 보기 | 이력해설 | 다운로드 (951 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
|
6 |
namespace KCOM.Common.Converter |
7 |
{ |
8 |
using System; |
9 |
using System.Windows.Data; |
10 |
using System.Windows.Media; |
11 |
using System.Globalization; |
12 |
using System.Windows; |
13 |
/// <summary> |
14 |
/// A Value converter |
15 |
/// </summary> |
16 |
public class NullToCollapsedConverter : IValueConverter |
17 |
{ |
18 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
19 |
{ |
20 |
Visibility result = Visibility.Collapsed; |
21 |
|
22 |
if (value != null) |
23 |
{ |
24 |
result = string.IsNullOrWhiteSpace(value?.ToString()) ? Visibility.Collapsed : Visibility.Visible; |
25 |
} |
26 |
|
27 |
return result; |
28 |
} |
29 |
|
30 |
|
31 |
|
32 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
33 |
{ |
34 |
throw new NotSupportedException(); |
35 |
} |
36 |
} |
37 |
} |