markus / KCOM / Common / Converter / BoolToVisibleConverter.cs @ 3abe8d4e
이력 | 보기 | 이력해설 | 다운로드 (1.39 KB)
1 | 787a4489 | KangIngu | 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 BoolToVisibleConverter : IValueConverter |
||
17 | { |
||
18 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||
19 | { |
||
20 | if (value != null) |
||
21 | { |
||
22 | if (value is bool) |
||
23 | { |
||
24 | if ((bool)value) |
||
25 | return Visibility.Visible; |
||
26 | else |
||
27 | return Visibility.Collapsed; |
||
28 | } |
||
29 | if (value is Int32) |
||
30 | { |
||
31 | return (int)value == 1 ? Visibility.Visible : Visibility.Collapsed; |
||
32 | } |
||
33 | |||
34 | else |
||
35 | { |
||
36 | throw new NotSupportedException("ConsolidationStringConverter bool만 가능합니다."); |
||
37 | } |
||
38 | } |
||
39 | else |
||
40 | { |
||
41 | return Visibility.Collapsed; |
||
42 | } |
||
43 | } |
||
44 | |||
45 | |||
46 | |||
47 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||
48 | { |
||
49 | throw new NotSupportedException(); |
||
50 | } |
||
51 | } |
||
52 | } |