aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Converters/BooleanToVisibilityInverseConverter.cs
blob: 475d2fca75b48697016380a22b4edef22161f384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace Tango.SharedUI.Converters
{
    /// <summary>
    /// Inversed binding converter for standard boolean to visibility and back.
    /// </summary>
    public class BooleanToVisibilityInverseConverter : IValueConverter
    {
        /// <summary>
        /// Converts a boolean value to visibility enumeration.
        /// </summary>
        /// <param name="value">Boolean value.</param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if ((bool)value) return Visibility.Collapsed;
            return Visibility.Visible;
        }

        /// <summary>
        /// Converts a visibility enumeration to boolean value.
        /// </summary>
        /// <param name="value">Visibility enumeration</param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if ((Visibility)value == Visibility.Visible) return false;
            else return true;
        }
    }
}