markus / KCOM / Common / Converter / ZeroToCollapsedConverter.cs @ a1cc6e1f
이력 | 보기 | 이력해설 | 다운로드 (1.13 KB)
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 ZeroToCollapsedConverter : IValueConverter |
17 |
{ |
18 |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
19 |
{ |
20 |
Visibility result = Visibility.Visible; |
21 |
|
22 |
if (value != null) |
23 |
{ |
24 |
try |
25 |
{ |
26 |
result = (double)value == 0 ? Visibility.Collapsed : Visibility.Visible; |
27 |
} |
28 |
catch (Exception) |
29 |
{ |
30 |
throw new NotSupportedException("ZeroToCollapsedConverter Double만 가능합니다."); |
31 |
} |
32 |
} |
33 |
|
34 |
return result; |
35 |
} |
36 |
|
37 |
|
38 |
|
39 |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
40 |
{ |
41 |
throw new NotSupportedException(); |
42 |
} |
43 |
} |
44 |
} |